add more tests for keyvaluepairloader (it had a bug previously) and fix up other...
authorAlec Warner <antarus@gentoo.org>
Mon, 23 Jul 2007 07:49:38 +0000 (07:49 -0000)
committerAlec Warner <antarus@gentoo.org>
Mon, 23 Jul 2007 07:49:38 +0000 (07:49 -0000)
svn path=/main/trunk/; revision=7371

pym/portage/tests/env/config/test_PackageMaskFile.py
pym/portage/tests/env/config/test_PortageModulesFile.py

index e8357f7e61b2754e60df6d33ef59affa27866289..4000f18071b358817facc6b6c873368964561011 100644 (file)
@@ -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):
index 03104cff5f182a830fa6df52f435fab7f12165e1..e4f9e4252b40604a961969af496542c3ba8abf7b 100644 (file)
@@ -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)