Package portage :: Package tests :: Package env :: Package config :: Module test_PackageUseFile
[hide private]

Source Code for Module portage.tests.env.config.test_PackageUseFile

 1  # test_PackageUseFile.py -- Portage Unit Testing Functionality 
 2  # Copyright 2007 Gentoo Foundation 
 3  # Distributed under the terms of the GNU General Public License v2 
 4   
 5  from portage import os 
 6  from portage.tests import TestCase 
 7  from portage.env.config import PackageUseFile 
 8  from tempfile import mkstemp 
 9   
10   
11 -class PackageUseFileTestCase(TestCase):
12 13 cpv = 'sys-apps/portage' 14 useflags = ['cdrom', 'far', 'boo', 'flag', 'blat'] 15
16 - def testPackageUseFile(self):
17 """ 18 A simple test to ensure the load works properly 19 """ 20 self.BuildFile() 21 try: 22 f = PackageUseFile(self.fname) 23 f.load() 24 for cpv, use in f.items(): 25 self.assertEqual(cpv, self.cpv) 26 [flag for flag in use if self.assertTrue(flag in self.useflags)] 27 finally: 28 self.NukeFile()
29
30 - def BuildFile(self):
31 fd, self.fname = mkstemp() 32 f = os.fdopen(fd, 'w') 33 f.write("%s %s" % (self.cpv, ' '.join(self.useflags))) 34 f.close()
35
36 - def NukeFile(self):
37 os.unlink(self.fname)
38