Пример #1
0
    def test_get(self):
        contents = StringIO('''
key=value
''')
        p = DotProperties(contents)
        self.assertEqual(p.get('missing'), None)
        self.assertEqual(p.get('missing', 'default'), 'default')
        self.assertEqual(p.get('key'), 'value')
Пример #2
0
    def test_get(self):
        contents = StringIO('''
key=value
''')
        p = DotProperties(contents)
        self.assertEqual(p.get('missing'), None)
        self.assertEqual(p.get('missing', 'default'), 'default')
        self.assertEqual(p.get('key'), 'value')
Пример #3
0
    def test_get(self):
        contents = StringIO("""
key=value
""")
        p = DotProperties(contents)
        self.assertEqual(p.get("missing"), None)
        self.assertEqual(p.get("missing", "default"), "default")
        self.assertEqual(p.get("key"), "value")
Пример #4
0
    def test_update(self):
        contents = StringIO('''
old=old value
key=value
''')
        p = DotProperties(contents)
        self.assertEqual(p.get('old'), 'old value')
        self.assertEqual(p.get('key'), 'value')

        new_contents = StringIO('''
key=new value
''')
        p.update(new_contents)
        self.assertEqual(p.get('old'), 'old value')
        self.assertEqual(p.get('key'), 'new value')
Пример #5
0
    def test_get_dict_with_value_prefix(self):
        contents = StringIO('''
A.default=A
A.default.B=B
A.default.B.ignored=B ignored
A.default.C=C
A.default.C.ignored=C ignored
''')
        p = DotProperties(contents)
        self.assertEqual(p.get('A.default'), 'A')
        # This enumerates the properties.
        self.assertEqual(p.get_dict('A.default'), {'B': 'B', 'C': 'C'})
        # They can still be fetched directly.
        self.assertEqual(p.get('A.default.B'), 'B')
        self.assertEqual(p.get('A.default.C'), 'C')
Пример #6
0
    def test_update(self):
        contents = StringIO('''
old=old value
key=value
''')
        p = DotProperties(contents)
        self.assertEqual(p.get('old'), 'old value')
        self.assertEqual(p.get('key'), 'value')

        new_contents = StringIO('''
key=new value
''')
        p.update(new_contents)
        self.assertEqual(p.get('old'), 'old value')
        self.assertEqual(p.get('key'), 'new value')
Пример #7
0
    def test_get_dict_with_value_prefix(self):
        contents = StringIO('''
A.default=A
A.default.B=B
A.default.B.ignored=B ignored
A.default.C=C
A.default.C.ignored=C ignored
''')
        p = DotProperties(contents)
        self.assertEqual(p.get('A.default'), 'A')
        # This enumerates the properties.
        self.assertEqual(p.get_dict('A.default'), {'B': 'B', 'C': 'C'})
        # They can still be fetched directly.
        self.assertEqual(p.get('A.default.B'), 'B')
        self.assertEqual(p.get('A.default.C'), 'C')
Пример #8
0
    def test_update(self):
        contents = StringIO("""
old=old value
key=value
""")
        p = DotProperties(contents)
        self.assertEqual(p.get("old"), "old value")
        self.assertEqual(p.get("key"), "value")

        new_contents = StringIO("""
key=new value
""")
        p.update(new_contents)
        self.assertEqual(p.get("old"), "old value")
        self.assertEqual(p.get("key"), "new value")
Пример #9
0
    def test_get_dict_with_value_prefix(self):
        contents = StringIO("""
A.default=A
A.default.B=B
A.default.B.ignored=B ignored
A.default.C=C
A.default.C.ignored=C ignored
""")
        p = DotProperties(contents)
        self.assertEqual(p.get("A.default"), "A")
        # This enumerates the properties.
        self.assertEqual(p.get_dict("A.default"), {"B": "B", "C": "C"})
        # They can still be fetched directly.
        self.assertEqual(p.get("A.default.B"), "B")
        self.assertEqual(p.get("A.default.C"), "C")