Example #1
0
    def test_load_dictionary(self):
        def assertEqual(a, b):
            self.assertEqual(a._dict, b)

        assertEqual(load_dictionary('{"S": "a"}'), {('S',): 'a'})
        assertEqual(load_dictionary('{"S": "\xc3\xb1"}'), {('S',): u'\xf1'})
        assertEqual(load_dictionary('{"S": "\xf1"}'), {('S',): u'\xf1'})
        
        with self.assertRaises(DictionaryLoaderException):
            load_dictionary('foo')
Example #2
0
    def test_load_dictionary(self):
        def assertEqual(a, b):
            self.assertEqual(a._dict, b)

        for contents, expected in (
            ('{"S": "a"}'       , {('S', ): 'a'    }),
            ('{"S": "\xc3\xb1"}', {('S', ): u'\xf1'}),
            ('{"S": "\xf1"}'    , {('S', ): u'\xf1'}),
        ):
            assertEqual(load_dictionary(make_dict(contents)), expected)
        
        with self.assertRaises(DictionaryLoaderException):
            load_dictionary(make_dict('foo'))
Example #3
0
    def test_load_dictionary(self):
        def assertEqual(a, b):
            self.assertEqual(a._dict, b)

        for contents, expected in (
            ('{"S": "a"}', {
                ('S', ): 'a'
            }),
            ('{"S": "\xc3\xb1"}', {
                ('S', ): u'\xf1'
            }),
            ('{"S": "\xf1"}', {
                ('S', ): u'\xf1'
            }),
        ):
            assertEqual(load_dictionary(make_dict(contents)), expected)

        with self.assertRaises(DictionaryLoaderException):
            load_dictionary(make_dict('foo'))