示例#1
0
    def test_deburr_fuzz(self):
        cf = config.ConfigFile()
        fuzzcount = 1000
        maxlength = 1000

        # For py2 compatibility
        if hasattr(__builtins__, "xrange"):
            myrange = xrange
        else:
            myrange = range

        for i in myrange(fuzzcount):
            argument1 = ''
            argument2 = ''
            length1 = random.randint(0, maxlength)
            length2 = random.randint(0, maxlength)
            for i in myrange(length1):
                character = random.randint(0, 255)
                argument1 = argument1 + chr(character)
            for i in myrange(length2):
                character = random.randint(0, 255)
                argument2 = argument2 + chr(character)
            wildint = random.randint(0, 1)
            wild = (wildint == 0)
            if (wild):
                cf.deburr(argument1)
            else:
                cf.deburr(argument1, argument2)
示例#2
0
 def test_deburr(self):
     cf = config.ConfigFile()
     self.assertEqual('', cf.deburr(''))
     self.assertEqual('', cf.deburr('', ''))
     self.assertEqual('', cf.deburr(' '))
     self.assertEqual('', cf.deburr('"', '"'))
     self.assertEqual('aa', cf.deburr('"aa"'))
     self.assertEqual('"', cf.deburr('"""'))
示例#3
0
 def test_printdump(self):
     cf = config.ConfigFile()
     oldstdout = sys.stdout
     sys.stdout = StringIO.StringIO()
     cf.printDump()
     output = sys.stdout.getvalue()
     sys.stdout.close()
     self.assertEqual('', output)
     sys.stdout = StringIO.StringIO()
     cf['foo'] = 'foo'
     cf['foo/bar'] = 'foobar1'
     cf['foo\\bar'] = 'foobar2'
     cf.printDump()
     output = sys.stdout.getvalue()
     sys.stdout.close()
     sys.stdout = oldstdout
     self.assertEqual('section  {\n}\n\nsection foo {\n}\n', output)
示例#4
0
 def test_lieaboutexistance(self):
     cf = config.ConfigFile('/dev/null', False)
示例#5
0
 def test_nonexistantfile(self):
     cf = config.ConfigFile('idontexist')
示例#6
0
 def test_emptyfile(self):
     cf = config.ConfigFile('/dev/null', True)
示例#7
0
 def test_noargs(self):
     cf = config.ConfigFile()
     self.assertEqual(False, cf.fileExists())
     expectedDump = []
     self.assertEqual(expectedDump, cf.dump())
     cf.write()
示例#8
0
 def test_template(self):
     cf = config.ConfigFile()
     cf.template('foo')
示例#9
0
 def test_circular(self):
     cf = config.ConfigFile()
     cf.setParent(cf)
示例#10
0
 def test_condsubitem(self):
     cf = config.ConfigFile()
     cf['foo'] = 'foo'
     self.assertEqual('foo', cf.condSubItem('foo', '%s'))
示例#11
0
 def test_sections(self):
     cf = config.ConfigFile()
     self.assertEqual([], cf.getSections())
示例#12
0
 def test_subitem(self):
     cf = config.ConfigFile()
     cf['foo/bar'] = 'foobar'
     self.assertEqual('blah foobar blah',
                      cf.subItem('foo/bar', 'blah %s blah'))
     self.assertEqual('', cf.subItem('notthere', 'blah %s blah', True))
示例#13
0
 def test_local_item(self):
     cf = config.ConfigFile()
     cf['foo'] = 'foo'
     self.assertEqual(True, cf.hasLocalItem('foo'))
     self.assertEqual(False, cf.hasLocalItem('bar'))
示例#14
0
 def test_setter_getter(self):
     cf = config.ConfigFile()
     cf['foo'] = 'foo'
     self.assertEqual('foo', cf['foo'])
示例#15
0
 def test_inherit(self):
     cf = config.ConfigFile()
     self.assertEqual(None, cf.inherit('foo'))
示例#16
0
 def test_parent(self):
     cf = config.ConfigFile()
     parent = config.ConfigFile()
     cf.setParent(parent)
示例#17
0
 def test_read(self):
     cf = config.ConfigFile()
     cf.readFromLines('section  {\n}\n\nsection foo {\n}\n')
示例#18
0
 def test_widecircle(self):
     cf = config.ConfigFile()
     parent = config.ConfigFile()
     cf.setParent(parent)
     parent.setParent(cf)
示例#19
0
 def test_nonconfigparent(file):
     cf = config.ConfigFile()
     cf.setParent(None)