Example #1
0
 def test_callable_key(self):
     formatter = JSONFormatter()
     formatter.configure(key=lambda x: x['foo'][::-1])
     h.assert_equal(formatter.render({'foo': 'bar'}), '"rab"')
Example #2
0
 def test_string_key(self):
     formatter = JSONFormatter()
     formatter.configure(key='foo')
     h.assert_equal(formatter.render({'foo': {
         'bar': 'baz'
     }}), '{"bar": "baz"}')
Example #3
0
    def test_no_key(self):
        formatter = JSONFormatter()
        formatter.configure()

        h.assert_equal(formatter.render({'foo': 'bar'}), '{"foo": "bar"}')
Example #4
0
 def test_callable_key(self):
     formatter = JSONFormatter()
     formatter.configure(key=lambda x: x['foo'][::-1])
     h.assert_equal(formatter.render({'foo': 'bar'}), '"rab"')
Example #5
0
 def test_string_key(self):
     formatter = JSONFormatter()
     formatter.configure(key='foo')
     h.assert_equal(formatter.render({'foo': {'bar': 'baz'}}), '{"bar": "baz"}')
Example #6
0
    def test_no_key(self):
        formatter = JSONFormatter()
        formatter.configure()

        h.assert_equal(formatter.render({'foo': 'bar'}), '{"foo": "bar"}')