From a3fca71d21d2c52a14ea7622145a6f8bf396aa12 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Thu, 28 Mar 2019 12:22:04 -0700 Subject: [PATCH] Use copies of passed lists in tests --- rbackup/tests/test_repository.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/rbackup/tests/test_repository.py b/rbackup/tests/test_repository.py index a4f2989..46adcff 100644 --- a/rbackup/tests/test_repository.py +++ b/rbackup/tests/test_repository.py @@ -87,7 +87,7 @@ class TestRepositoryPostCreate(unittest.TestCase): @given(lists(builds(Snapshot, text()), unique=True)) def test_empty(self, l): - self.repo_snapshots.return_value = l + self.repo_snapshots.return_value = l.copy() repo = Repository('backup') repo.create_snapshot() @@ -96,23 +96,21 @@ class TestRepositoryPostCreate(unittest.TestCase): @given(lists(builds(Snapshot, text()), unique=True)) def test_len(self, l): - self.repo_snapshots.return_value = l + self.repo_snapshots.return_value = l.copy() repo = Repository('backup') repo.create_snapshot() - # Did the repository add the snapshot to its internal list? - self.assertEqual(len(repo.snapshots), len(l)) + self.assertEqual(len(repo.snapshots), len(l) + 1) @given(lists(builds(Snapshot, text()), unique=True)) def test_current_snapshot(self, l): - self.repo_snapshots.return_value = l + self.repo_snapshots.return_value = l.copy() repo = Repository('backup') new_snapshot = repo.create_snapshot() - self.assertIs(new_snapshot, l[-1]) - self.assertIs(repo.current_snapshot, l[-1]) + self.assertIs(new_snapshot, repo.current_snapshot) self.assertIsInstance(new_snapshot, Snapshot) def tearDown(self):