From 6b37f5f1de6fb813056fc994cd7fa776996b659e Mon Sep 17 00:00:00 2001 From: masklinn Date: Tue, 11 Mar 2014 10:16:30 +0100 Subject: Test copy-with-replacement and invalid copy Styllistic fixes, ensure compatibility with pre-2.7 unittest --- fastimport/tests/test_commands.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fastimport/tests/test_commands.py b/fastimport/tests/test_commands.py index 12a3772..a8f39d4 100644 --- a/fastimport/tests/test_commands.py +++ b/fastimport/tests/test_commands.py @@ -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): -- cgit v1.2.1