fix some tests, break others
authorAlec Warner <antarus@gentoo.org>
Mon, 26 Mar 2007 04:29:29 +0000 (04:29 -0000)
committerAlec Warner <antarus@gentoo.org>
Mon, 26 Mar 2007 04:29:29 +0000 (04:29 -0000)
svn path=/main/trunk/; revision=6287

pym/portage/tests/env/config/test_PackageKeywordsFile.py
pym/portage/tests/env/config/test_PackageUseFile.py
pym/portage/tests/env/config/test_PortageModulesFile.py [new file with mode: 0644]

index 229d9dffe4135bad6bef237c16c1d8f168a073c4..fb053153b580245bfbdb1b3b930ae37394cba044 100644 (file)
@@ -10,7 +10,7 @@ import os
 
 class PackageKeywordsFileTestCase(TestCase):
 
-       cpv = 'sys-apps/portage'
+       cpv = ['sys-apps/portage']
        keywords = ['~x86', 'amd64', '-mips']
        
        def testPackageKeywordsFile(self):
@@ -22,16 +22,19 @@ class PackageKeywordsFileTestCase(TestCase):
                try:
                        f = PackageKeywordsFile(self.fname)
                        f.load()
+                       i = 0
                        for cpv, keyword in f.iteritems():
-                               self.assertEqual( cpv, self.cpv )
+                               self.assertEqual( cpv, self.cpv[i] )
                                [k for k in keyword if self.assertTrue(k in self.keywords)]
+                               i = i + 1
                finally:
                        self.NukeFile()
        
        def BuildFile(self):
                fd, self.fname = mkstemp()
                f = os.fdopen(fd, 'w')
-               f.write("\n".join(self.atoms))
+               for c in self.cpv:
+                       f.write("%s %s\n" % (c,' '.join(self.keywords)))
                f.close()
 
        def NukeFile(self):
index d20ab4572ff786c143644741c2dcada587d231fb..93474b6f7d19a8a6977ed2bc233b804358112868 100644 (file)
@@ -30,8 +30,9 @@ class PackageUseFileTestCase(TestCase):
 
        def BuildFile(self):
                fd, self.fname = mkstemp()
-               f = os.fdopen(self.fname, 'wb')
+               f = os.fdopen(fd, 'wb')
                f.write("%s %s" % (self.cpv, ' '.join(self.useflags)))
+               f.close()
        
        def NukeFile(self):
                import os
diff --git a/pym/portage/tests/env/config/test_PortageModulesFile.py b/pym/portage/tests/env/config/test_PortageModulesFile.py
new file mode 100644 (file)
index 0000000..4d1b481
--- /dev/null
@@ -0,0 +1,31 @@
+import os
+
+from portage.tests import TestCase
+from portage.env.config import PortageModulesFile
+from tempfile import mkstemp
+
+class PortageModulesFileTestCase(TestCase):
+
+       keys = ['foo.bar','baz','bob','extra_key']
+       modules = ['spanky','zmedico','antarus','ricer']
+
+       def setUp(self):
+               for k,v in (self.keys, self.modules):
+                       self.items[k] = v
+
+       def testPortageModulesFile(self):
+               self.BuildFile()
+               f = PortageModulesFile(self.fname)
+               for k in f.keys():
+                       self.assertEqual( f[k], self.items[k] )
+               self.NukeFile()
+
+       def BuildFile(self):
+               fd,self.fname = mkstemp()
+               f = os.fdopen(self.fname, 'wb')
+               f.write('%s %s\n' % (self.cpv, ' '.join(self.keywords)))
+               f.close()
+
+       def NukeFile(self):
+               import os
+               os.unlink(self.fname)