diff options
-rw-r--r-- | pym/portage/tests/env/config/test_PackageMaskFile.py | 8 | ||||
-rw-r--r-- | pym/portage/tests/env/config/test_PortageModulesFile.py | 18 |
2 files changed, 14 insertions, 12 deletions
diff --git a/pym/portage/tests/env/config/test_PackageMaskFile.py b/pym/portage/tests/env/config/test_PackageMaskFile.py index e8357f7e6..4000f1807 100644 --- a/pym/portage/tests/env/config/test_PackageMaskFile.py +++ b/pym/portage/tests/env/config/test_PackageMaskFile.py @@ -6,12 +6,10 @@ import os from portage.env.config import PackageMaskFile -from portage.tests import TestCase +from portage.tests import TestCase, test_cps from tempfile import mkstemp class PackageMaskFileTestCase(TestCase): - - atoms = ['sys-apps/portage','dev-util/diffball','not@va1id@t0m'] def testPackageMaskFile(self): self.BuildFile() @@ -19,14 +17,14 @@ class PackageMaskFileTestCase(TestCase): f = PackageMaskFile(self.fname) f.load() for atom in f: - self.assertTrue(atom in self.atoms) + self.assertTrue(atom in test_cps) finally: self.NukeFile() def BuildFile(self): fd, self.fname = mkstemp() f = os.fdopen(fd, 'w') - f.write("\n".join(self.atoms)) + f.write("\n".join(test_cps)) f.close() def NukeFile(self): diff --git a/pym/portage/tests/env/config/test_PortageModulesFile.py b/pym/portage/tests/env/config/test_PortageModulesFile.py index 03104cff5..e4f9e4252 100644 --- a/pym/portage/tests/env/config/test_PortageModulesFile.py +++ b/pym/portage/tests/env/config/test_PortageModulesFile.py @@ -1,34 +1,38 @@ -import os from portage.tests import TestCase from portage.env.config import PortageModulesFile from tempfile import mkstemp from itertools import izip +import os class PortageModulesFileTestCase(TestCase): keys = ['foo.bar','baz','bob','extra_key'] - modules = ['spanky','zmedico','antarus','ricer'] + invalid_keys = ['',""] + modules = ['spanky','zmedico','antarus','ricer','5','6'] def setUp(self): self.items = {} - for k,v in izip(self.keys, self.modules): + for k, v in izip(self.keys + self.invalid_keys, + self.modules): self.items[k] = v def testPortageModulesFile(self): self.BuildFile() f = PortageModulesFile(self.fname) - for k in f: - self.assertEqual( f[k], self.items[k] ) + f.load() + for k in self.keys: + self.assertEqual(f[k], [self.items[k]]) + for ik in self.invalid_keys: + self.assertEqual(False, ik in f) self.NukeFile() def BuildFile(self): fd, self.fname = mkstemp() f = os.fdopen(fd, 'wb') - for k,v in self.items.iteritems(): + for k, v in self.items.iteritems(): f.write('%s=%s\n' % (k,v)) f.close() def NukeFile(self): - import os os.unlink(self.fname) |