Exemple #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)
Exemple #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('"""'))
Exemple #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)
Exemple #4
0
 def test_lieaboutexistance(self):
     cf = config.ConfigFile('/dev/null', False)
Exemple #5
0
 def test_nonexistantfile(self):
     cf = config.ConfigFile('idontexist')
Exemple #6
0
 def test_emptyfile(self):
     cf = config.ConfigFile('/dev/null', True)
Exemple #7
0
 def test_noargs(self):
     cf = config.ConfigFile()
     self.assertEqual(False, cf.fileExists())
     expectedDump = []
     self.assertEqual(expectedDump, cf.dump())
     cf.write()
Exemple #8
0
 def test_template(self):
     cf = config.ConfigFile()
     cf.template('foo')
Exemple #9
0
 def test_circular(self):
     cf = config.ConfigFile()
     cf.setParent(cf)
Exemple #10
0
 def test_condsubitem(self):
     cf = config.ConfigFile()
     cf['foo'] = 'foo'
     self.assertEqual('foo', cf.condSubItem('foo', '%s'))
Exemple #11
0
 def test_sections(self):
     cf = config.ConfigFile()
     self.assertEqual([], cf.getSections())
Exemple #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))
Exemple #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'))
Exemple #14
0
 def test_setter_getter(self):
     cf = config.ConfigFile()
     cf['foo'] = 'foo'
     self.assertEqual('foo', cf['foo'])
Exemple #15
0
 def test_inherit(self):
     cf = config.ConfigFile()
     self.assertEqual(None, cf.inherit('foo'))
Exemple #16
0
 def test_parent(self):
     cf = config.ConfigFile()
     parent = config.ConfigFile()
     cf.setParent(parent)
Exemple #17
0
 def test_read(self):
     cf = config.ConfigFile()
     cf.readFromLines('section  {\n}\n\nsection foo {\n}\n')
Exemple #18
0
 def test_widecircle(self):
     cf = config.ConfigFile()
     parent = config.ConfigFile()
     cf.setParent(parent)
     parent.setParent(cf)
Exemple #19
0
 def test_nonconfigparent(file):
     cf = config.ConfigFile()
     cf.setParent(None)