85ab60753c33

Refactor the author line generation in tests.  It's much cleaner now.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 10 Oct 2009 10:51:02 -0400
parents dd45f9a0b74b
children 68e589a7c8c4
branches/tags (none)
files review/tests/test_comment.py review/tests/test_diffs.py

Changes

--- a/review/tests/test_comment.py	Fri Oct 09 23:41:51 2009 -0400
+++ b/review/tests/test_comment.py	Sat Oct 10 10:51:02 2009 -0400
@@ -6,6 +6,9 @@
 from mercurial import util as hgutil
 
 
+a1, a2 = (messages.REVIEW_LOG_COMMENT_AUTHOR % '|').split('|')
+
+
 @with_setup(setup_reviewed_sandbox, teardown_sandbox)
 def test_no_comments():
     sandbox = get_sandbox_repo()
@@ -36,8 +39,6 @@
     output = review()
     assert messages.REVIEW_LOG_COMMENTS % (1, 1) in output
     
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
     assert a1 in output
     assert a2 in output
     
@@ -60,8 +61,6 @@
     output = review(rev='0')
     assert messages.REVIEW_LOG_COMMENTS % (1, 1) in output
     
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
     assert a1 in output
     assert a2 in output
     
@@ -83,9 +82,6 @@
 def test_add_comments_to_file():
     sandbox = get_sandbox_repo()
     
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
-    
     review(comment=True, message='Test comment one.', rev='1', files=['file_one'])
     
     output = review(rev='1', files=['file_one'])
@@ -127,10 +123,7 @@
         assert messages.COMMENT_LINES_REQUIRE_FILE in error
     else:
         assert False, 'The correct error message was not printed.'
-    
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
-    
+        
     review(comment=True, rev='1', message='Test comment one.',
         files=['file_one'], lines='1')
     
@@ -153,9 +146,6 @@
 def test_add_comments_to_file_lines():
     sandbox = get_sandbox_repo()
     
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
-    
     review(comment=True, rev='1', message='Test comment one.',
         files=['file_one'], lines='1,2')
     
@@ -176,11 +166,7 @@
 
 @with_setup(setup_reviewed_sandbox, teardown_sandbox)
 def test_add_comments_to_file_in_subdir():
-    sandbox = get_sandbox_repo()
-    
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
-    
+    sandbox = get_sandbox_repo()    
     filename = os.path.join('test_dir', 'test_file')
     
     review(comment=True, message='Test comment one.', rev='1', files=[filename])
@@ -203,11 +189,7 @@
 def test_add_comments_to_file_in_cwd():
     sandbox = get_sandbox_repo()
     
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
-    
     os.chdir('test_dir')
-    
     review(comment=True, message='Test comment one.', rev='1', files=['test_file'])
     
     output = review(rev='1', files=['test_file'])
@@ -226,15 +208,10 @@
 
 @with_setup(setup_reviewed_sandbox, teardown_sandbox)
 def test_add_comments_to_file_in_reldir():
-    sandbox = get_sandbox_repo()
-    
-    author_line = messages.REVIEW_LOG_COMMENT_AUTHOR % '|'
-    a1, _, a2 = author_line.partition('|')
-    
+    sandbox = get_sandbox_repo()    
     filename = os.path.join('..', 'file_three')
     
     os.chdir('test_dir')
-    
     review(comment=True, message='Test comment one.', rev='1', files=[filename])
     
     output = review(rev='1', files=[filename])
--- a/review/tests/test_diffs.py	Fri Oct 09 23:41:51 2009 -0400
+++ b/review/tests/test_diffs.py	Sat Oct 10 10:51:02 2009 -0400
@@ -5,6 +5,10 @@
 import os
 
 
+a1, a2 = (messages.REVIEW_LOG_COMMENT_AUTHOR % '|').split('|')
+s1, s2 = (messages.REVIEW_LOG_SKIPPED % 1111).split('1111')
+
+
 @with_setup(setup_reviewed_sandbox, teardown_sandbox)
 def test_review_diff_default_context():
     sandbox = get_sandbox_repo()
@@ -32,7 +36,6 @@
     
     output = review(rev='1', files=['long_file'], unified='10000')
     
-    s1, s2 = (messages.REVIEW_LOG_SKIPPED % 1111).split('1111')
     assert s1 not in output
     assert s2 not in output
     
@@ -54,7 +57,7 @@
     
     assert '10:' not in output
     assert messages.REVIEW_LOG_SKIPPED % 2 in output
-
+    
     assert '-m' in output
     assert '+Y' in output