From 9caebb790345d4351051f97c9e7341aa2af0c808 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Wed, 25 Oct 2017 10:14:07 +0200 Subject: manifest: Wipe old entries when loading next file --- gemato/manifest.py | 3 ++- tests/test_manifest.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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): """ -- cgit v1.2.3