def test_json(): # Write contents storage = JSONStorage(path) storage.write(element) # Verify contents assert_equal(element, storage.read())
def test_no_error_json_storage(thing): storage = JSONStorage('./noerrors.json') storage.write(thing) assert thing == storage.read() storage.close()
def test_json(tmpdir): # Write contents path = str(tmpdir.join('test.db')) storage = JSONStorage(path) storage.write(element) # Verify contents assert element == storage.read()
def test_json(tmpdir): # Write contents path = str(tmpdir.join('test.db')) storage = JSONStorage(path) storage.write(doc) # Verify contents assert doc == storage.read() storage.close()
def test_encoding(tmpdir): japanese_doc = {"Test": u"こんにちは世界"} path = str(tmpdir.join('test.db')) # cp936 is used for japanese encodings jap_storage = JSONStorage(path, encoding="cp936") jap_storage.write(japanese_doc) try: exception = json.decoder.JSONDecodeError except AttributeError: exception = ValueError with pytest.raises(exception): # cp037 is used for english encodings eng_storage = JSONStorage(path, encoding="cp037") eng_storage.read() jap_storage = JSONStorage(path, encoding="cp936") assert japanese_doc == jap_storage.read()