diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-10-25 10:14:07 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-10-25 10:14:07 +0200 |
commit | 9caebb790345d4351051f97c9e7341aa2af0c808 (patch) | |
tree | 9c96276e65fa9e9db98507d3bfdade98831cbd63 | |
parent | 574879859ab0003d3158dd8fbbcc0645c775eaa9 (diff) | |
download | gemato-9caebb790345d4351051f97c9e7341aa2af0c808.tar.gz |
manifest: Wipe old entries when loading next file
-rw-r--r-- | gemato/manifest.py | 3 | ||||
-rw-r--r-- | tests/test_manifest.py | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/gemato/manifest.py b/gemato/manifest.py index 78462f4..96b1110 100644 --- a/gemato/manifest.py +++ b/gemato/manifest.py @@ -284,8 +284,8 @@ class ManifestFile(object): Create a new instance. If @f is provided, reads the entries from open Manifest file @f (see load()). """ - self.entries = [] + self.entries = [] if f is not None: self.load(f) @@ -295,6 +295,7 @@ class ManifestFile(object): in text mode, and oriented at the beginning. """ + self.entries = [] for l in f: sl = l.strip().split() # skip empty lines diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 18fe099..8fd3b9c 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -104,6 +104,17 @@ class ManifestTest(unittest.TestCase): self.assertListEqual(list(m.find_manifests_for_path('eclass/foo.eclass')), [m.find_path_entry('eclass/Manifest')]) + def test_multiple_load(self): + """ + Test that calling load() multiple times overwrites previously + loaded data. + """ + m = gemato.manifest.ManifestFile() + m.load(io.StringIO(TEST_MANIFEST)) + m.load(io.StringIO(TEST_DEPRECATED_MANIFEST)) + self.assertIsNone(m.find_timestamp()) + self.assertIsNone(m.find_path_entry('eclass/Manifest')) + class ManifestEntryTest(unittest.TestCase): """ |