Test copy-with-replacement and invalid copy
authormasklinn <bitbucket.org@masklinn.net>
Tue, 11 Mar 2014 09:16:30 +0000 (10:16 +0100)
committermasklinn <bitbucket.org@masklinn.net>
Tue, 11 Mar 2014 09:16:30 +0000 (10:16 +0100)
Styllistic fixes, ensure compatibility with pre-2.7 unittest

fastimport/tests/test_commands.py

index 12a3772b52ae22c71a0d5601321bf2edc51c88ca..a8f39d4c75aa398019b0506bba5896996ebd983d 100644 (file)
@@ -198,24 +198,35 @@ class TestCommitDisplay(TestCase):
             repr(c))
 
 class TestCommitCopy(TestCase):
+
     def setUp(self):
         super(TestCommitCopy, self).setUp()
         file_cmds = iter([
             commands.FileDeleteCommand('readme.txt'),
             commands.FileModifyCommand('NEWS', 0100644, None, 'blah blah blah'),
         ])
-        # user tuple is (name, email, secs-since-epoch, secs-offset-from-utc)
+
         committer = ('Joe Wong', 'joe@example.com', 1234567890, -6 * 3600)
         self.c = commands.CommitCommand(
             "refs/heads/master", "bbb", None, committer,
             "release v1.0", ":aaa", None, file_cmds)
 
-    def test_noop(self):
+    def test_simple_copy(self):
         c2 = self.c.copy()
 
-        self.assertIsNot(self.c, c2)
+        self.assertFalse(self.c is c2)
         self.assertEqual(repr(self.c), repr(c2))
 
+    def test_replace_attr(self):
+        c2 = self.c.copy(mark='ccc')
+
+        self.assertEqual(
+            repr(self.c).replace('mark :bbb', 'mark :ccc'),
+            repr(c2))
+
+    def test_invalid_attribute(self):
+        self.assertRaises(TypeError, self.c.copy, invalid=True)
+
 class TestFeatureDisplay(TestCase):
 
     def test_feature(self):