# HG changeset patch # User Steve Losh # Date 1254708869 14400 # Node ID 12aeab05829a8cbe17742958f08f1ae40eb3e391 # Parent e91ac244e5adcaf1e800779585733c3e836ae6b0 Wrap the test output in a more elegant way. diff -r e91ac244e5ad -r 12aeab05829a review/tests/test_comment.py --- a/review/tests/test_comment.py Sun Oct 04 22:08:06 2009 -0400 +++ b/review/tests/test_comment.py Sun Oct 04 22:14:29 2009 -0400 @@ -10,9 +10,7 @@ def test_no_comments(): sandbox = get_sandbox_repo() - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_COMMENTS % (0, 0) in output @@ -35,16 +33,12 @@ review(comment=True, message='Test comment one.') - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_COMMENTS % (1, 1) in output review(comment=True, message='Test comment two.') - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_COMMENTS % (2, 1) in output @@ -54,20 +48,14 @@ review(comment=True, message='Test comment one.', rev='0') - gather_output() - review(rev='0') - output = grab_output() + output = review(rev='0') assert messages.REVIEW_LOG_COMMENTS % (1, 1) in output - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_COMMENTS % (0, 0) in output review(comment=True, message='Test comment two.', rev='0') - gather_output() - review(rev='0') - output = grab_output() + output = review(rev='0') assert messages.REVIEW_LOG_COMMENTS % (2, 1) in output diff -r e91ac244e5ad -r 12aeab05829a review/tests/test_init.py --- a/review/tests/test_init.py Sun Oct 04 22:08:06 2009 -0400 +++ b/review/tests/test_init.py Sun Oct 04 22:14:29 2009 -0400 @@ -10,9 +10,7 @@ def test_init(): sandbox = get_sandbox_repo() - gather_output() - review(init=True) - output = grab_output() + output = review(init=True) assert messages.INIT_SUCCESS in output assert '.hgreview' not in sandbox['tip'] @@ -30,9 +28,7 @@ def test_init_with_local_path(): sandbox = get_sandbox_repo() - gather_output() - review(init=True, local_path='codereview') - output = grab_output() + output = review(init=True, local_path='codereview') assert messages.INIT_SUCCESS in output assert '.hgreview' not in sandbox['tip'] @@ -50,9 +46,7 @@ def test_init_with_remote_path(): sandbox = get_sandbox_repo() - gather_output() - review(init=True, remote_path='../code-review') - output = grab_output() + output = review(init=True, remote_path='../code-review') assert messages.INIT_SUCCESS in output assert '.hgreview' not in sandbox['tip'] @@ -70,9 +64,7 @@ def test_init_with_both_paths(): sandbox = get_sandbox_repo() - gather_output() - review(init=True, local_path='codereview', remote_path='../code-review') - output = grab_output() + output = review(init=True, local_path='codereview', remote_path='../code-review') assert messages.INIT_SUCCESS in output assert '.hgreview' not in sandbox['tip'] @@ -90,9 +82,10 @@ def test_init_twice(): sandbox = get_sandbox_repo() + review(init=True) + try: review(init=True) - review(init=True) except hgutil.Abort, e: error = str(e) assert messages.INIT_EXISTS_UNCOMMITTED in error diff -r e91ac244e5ad -r 12aeab05829a review/tests/test_signoff.py --- a/review/tests/test_signoff.py Sun Oct 04 22:08:06 2009 -0400 +++ b/review/tests/test_signoff.py Sun Oct 04 22:14:29 2009 -0400 @@ -10,9 +10,7 @@ def test_no_comments(): sandbox = get_sandbox_repo() - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_SIGNOFFS % 0 in output @@ -35,9 +33,7 @@ review(signoff=True, message='Test signoff one.') - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_SIGNOFFS % 1 in output @@ -47,14 +43,10 @@ review(signoff=True, message='Test signoff one.', rev='0') - gather_output() - review(rev='0') - output = grab_output() + output = review(rev='0') assert messages.REVIEW_LOG_SIGNOFFS % 1 in output - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_SIGNOFFS % 0 in output @@ -74,8 +66,6 @@ review(signoff=True, message='Test signoff two.', force=True) - gather_output() - review() - output = grab_output() + output = review() assert messages.REVIEW_LOG_SIGNOFFS % 1 in output diff -r e91ac244e5ad -r 12aeab05829a review/tests/util.py --- a/review/tests/util.py Sun Oct 04 22:08:06 2009 -0400 +++ b/review/tests/util.py Sun Oct 04 22:14:29 2009 -0400 @@ -7,10 +7,16 @@ _ui = ui.ui() def review(init=False, comment=False, signoff=False, yes=False, no=False, force=False, message='', rev='.', local_path='', remote_path=''): - return extension_ui.review(_ui, get_sandbox_repo(), + + _ui.pushbuffer() + extension_ui.review(_ui, get_sandbox_repo(), init=init, comment=comment, signoff=signoff, yes=yes, no=no, force=force, message=message, rev=rev, local_path=local_path, remote_path=remote_path) + output = _ui.popbuffer() + + print output + return output sandbox_path = os.path.join(os.path.realpath('.'), 'sandbox') @@ -50,12 +56,3 @@ def get_datastore_repo(path): return hg.repository(_ui, path) - -def gather_output(): - _ui.pushbuffer() - -def grab_output(): - output = _ui.popbuffer() - print output - - return output