Пример #1
0
def test_all_resulting_objects_are_Context_instances():
    obj = jsobj.loads('''{
        "nested": {
            "value": 123.5
        }
    }''')
    assert isinstance(obj, jsobj)
    assert isinstance(obj.nested, jsobj)
Пример #2
0
def test_raises_TypeError_if_argument_is_not_a_string():
    with pytest.raises(TypeError):
        jsobj.loads(123)

    with pytest.raises(TypeError):
        jsobj.loads({})

    with pytest.raises(TypeError):
        jsobj.loads(123.5)
Пример #3
0
def test_unicode_shows_json_string(test_obj):
    obj = jsobj.loads(test_obj.__unicode__())
    assert obj == test_obj
Пример #4
0
def test_str_shows_json_string(test_obj):
    obj = jsobj.loads(str(test_obj))
    assert obj == test_obj
Пример #5
0
def test_raises_ValueError_if_invalid_json_string_is_passed():
    with pytest.raises(ValueError):
        jsobj.loads('invalid JSON string')