Пример #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)