diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-02-28 14:13:09 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-02-28 14:13:09 +0000 |
commit | dadb4f295c51e3fbb29886cccab5a6beceabe60b (patch) | |
tree | 76267e17106935af8f91b1b3cb1b10337d07dff1 /morphlib/bins_tests.py | |
parent | 93de61c7dfa4c0e5db9bbfecec210da8582d8174 (diff) | |
download | morph-dadb4f295c51e3fbb29886cccab5a6beceabe60b.tar.gz |
Refactor tests to share more common code
Diffstat (limited to 'morphlib/bins_tests.py')
-rw-r--r-- | morphlib/bins_tests.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/morphlib/bins_tests.py b/morphlib/bins_tests.py index 1d0eb2bf..82ceb246 100644 --- a/morphlib/bins_tests.py +++ b/morphlib/bins_tests.py @@ -103,29 +103,32 @@ class ChunkTests(BinsTest): pass os.utime(filename, (timestamp, timestamp)) - def test_empties_everything(self): + self.instdir_orig_files = self.recursive_lstat(self.instdir) + + def create_chunk(self, regexps): self.populate_instdir() - morphlib.bins.create_chunk(self.instdir, self.chunk_f, ['.'], self.ex) + morphlib.bins.create_chunk(self.instdir, self.chunk_f, regexps, + self.ex) self.chunk_f.flush() + + def unpack_chunk(self): + os.mkdir(self.unpacked) + morphlib.bins.unpack_binary(self.chunk_file, self.unpacked, self.ex) + + def test_empties_everything(self): + self.create_chunk(['.']) self.assertEqual([x for x,y in self.recursive_lstat(self.instdir)], ['.']) def test_creates_and_unpacks_chunk_exactly(self): - self.populate_instdir() - orig_files = self.recursive_lstat(self.instdir) - morphlib.bins.create_chunk(self.instdir, self.chunk_f, ['.'], self.ex) - self.chunk_f.flush() - os.mkdir(self.unpacked) - morphlib.bins.unpack_binary(self.chunk_file, self.unpacked, self.ex) - self.assertEqual(orig_files, self.recursive_lstat(self.unpacked)) + self.create_chunk(['.']) + self.unpack_chunk() + self.assertEqual(self.instdir_orig_files, + self.recursive_lstat(self.unpacked)) def test_uses_only_matching_names(self): - self.populate_instdir() - morphlib.bins.create_chunk(self.instdir, self.chunk_f, ['bin'], - self.ex) - self.chunk_f.flush() - os.mkdir(self.unpacked) - morphlib.bins.unpack_binary(self.chunk_file, self.unpacked, self.ex) + self.create_chunk(['bin']) + self.unpack_chunk() self.assertEqual([x for x,y in self.recursive_lstat(self.unpacked)], ['.', 'bin', 'bin/foo']) self.assertEqual([x for x,y in self.recursive_lstat(self.instdir)], |