Add return type to tests without arguments (#87613)

* Add return type to tests without arguments

* Black

* Cancel fixture amends
This commit is contained in:
epenet 2023-02-07 14:20:06 +01:00 committed by GitHub
parent fb4c0b4b7a
commit 4142f0d15d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 473 additions and 459 deletions

View file

@ -44,7 +44,7 @@ def _path_for(leaf_name):
return os.path.join(TMP_DIR, f"{leaf_name}.json")
def test_save_and_load():
def test_save_and_load() -> None:
"""Test saving and loading back."""
fname = _path_for("test1")
save_json(fname, TEST_JSON_A)
@ -52,7 +52,7 @@ def test_save_and_load():
assert data == TEST_JSON_A
def test_save_and_load_int_keys():
def test_save_and_load_int_keys() -> None:
"""Test saving and loading back stringifies the keys."""
fname = _path_for("test1")
save_json(fname, {1: "a", 2: "b"})
@ -60,7 +60,7 @@ def test_save_and_load_int_keys():
assert data == {"1": "a", "2": "b"}
def test_save_and_load_private():
def test_save_and_load_private() -> None:
"""Test we can load private files and that they are protected."""
fname = _path_for("test2")
save_json(fname, TEST_JSON_A, private=True)
@ -80,7 +80,7 @@ def test_overwrite_and_reload(atomic_writes):
assert data == TEST_JSON_B
def test_save_bad_data():
def test_save_bad_data() -> None:
"""Test error from trying to save unserializable data."""
class CannotSerializeMe:
@ -94,7 +94,7 @@ def test_save_bad_data():
)
def test_load_bad_data():
def test_load_bad_data() -> None:
"""Test error from trying to load unserialisable data."""
fname = _path_for("test5")
with open(fname, "w") as fh:
@ -103,7 +103,7 @@ def test_load_bad_data():
load_json(fname)
def test_custom_encoder():
def test_custom_encoder() -> None:
"""Test serializing with a custom encoder."""
class MockJSONEncoder(JSONEncoder):
@ -119,7 +119,7 @@ def test_custom_encoder():
assert data == "9"
def test_default_encoder_is_passed():
def test_default_encoder_is_passed() -> None:
"""Test we use orjson if they pass in the default encoder."""
fname = _path_for("test6")
with patch(
@ -134,7 +134,7 @@ def test_default_encoder_is_passed():
assert data == {"any": [1]}
def test_find_unserializable_data():
def test_find_unserializable_data() -> None:
"""Find unserializeable data."""
assert find_paths_unserializable_data(1) == {}
assert find_paths_unserializable_data([1, 2]) == {}