示例#1
0
    def test_get_django_settings(self):
        class MySchema(Schema):
            foo = IntOption()
            bar = DictOption(spec={'baz': IntOption(), 'BAZ': IntOption()})

        expected = {'FOO': 0, 'BAR': {'baz': 0, 'BAZ': 0}}

        parser = SchemaConfigParser(MySchema())
        result = get_django_settings(parser)
        self.assertEqual(result, expected)
示例#2
0
    def test_get_django_settings_encoding(self):
        class MySchema(Schema):
            foo = StringOption()

        expected = {'FOO': u'€'.encode(SETTINGS_ENCODING)}

        config = StringIO(u'[__main__]\nfoo=€'.encode(CONFIG_FILE_ENCODING))
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)
        self.assertEqual(parser.values('__main__'), {'foo': u'€'})
        result = get_django_settings(parser)
        self.assertEqual(result, expected)
    def test_get_django_settings_encoding(self):
        class MySchema(Schema):
            foo = StringOption()

        expected = {'FOO': u'€'.encode(SETTINGS_ENCODING)}

        config = StringIO(u'[__main__]\nfoo=€'.encode(CONFIG_FILE_ENCODING))
        parser = SchemaConfigParser(MySchema())
        parser.readfp(config)
        self.assertEqual(parser.values('__main__'), {'foo': u'€'})
        result = get_django_settings(parser)
        self.assertEqual(result, expected)
    def test_get_django_settings(self):
        class MySchema(Schema):
            foo = IntOption()
            bar = DictOption(
                spec={'baz': IntOption(),
                      'BAZ': IntOption()})

        expected = {'FOO': 0, 'BAR': {'baz': 0, 'BAZ': 0}}

        parser = SchemaConfigParser(MySchema())
        result = get_django_settings(parser)
        self.assertEqual(result, expected)