Exemple #1
0
 def test_none(self):
     with pytest.raises(FormattingError,
                        match='Unexpected type for JSON input.'):
         input_format.json(None)
Exemple #2
0
 def test_random_string(self):
     with pytest.raises(FormattingError, match='Invalid JSON input.'):
         input_format.json('sadfawfopq2yr923')
Exemple #3
0
 def test_empty_string(self):
     with pytest.raises(FormattingError, match='Invalid JSON input.'):
         input_format.json('')
Exemple #4
0
 def test_empty_content(self):
     assert {} == input_format.json('{}')
Exemple #5
0
 def test_valid_nested_dict(self):
     assert {
         'person': {
             'name': 'Peter'
         }
     } == input_format.json('{"person": {"name": "Peter"}}')
Exemple #6
0
 def test_valid_bool_dict(self):
     assert {'is_valid': True} == input_format.json('{"is_valid": true}')
Exemple #7
0
 def test_valid_int_dict(self):
     assert {'score': 100} == input_format.json('{"score": 100}')
Exemple #8
0
 def test_valid_string_dict(self):
     assert {'name': 'Peter'} == input_format.json('{"name": "Peter"}')