1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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']
invalid_keys = ['',""]
modules = ['spanky','zmedico','antarus','ricer','5','6']
def setUp(self):
self.items = {}
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)
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, 'w')
for k, v in self.items.iteritems():
f.write('%s=%s\n' % (k,v))
f.close()
def NukeFile(self):
os.unlink(self.fname)
|