Skip to content

Commit fd4c793

Browse files
committed
fix: Move json import to module level in tests
Per Copilot review, import statements should be at the module level for consistency and readability. Moved all 'import json' statements from inside test functions to the top of test_api.py. - Added 'import json' to module imports (line 13) - Removed 3 inline imports from test functions - All tests still passing (11/11) - Code quality checks pass (ruff, mypy)
1 parent e35585f commit fd4c793

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

tests/test_api.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
Python type normalization is tested in test_normalization.py.
1111
"""
1212

13+
import json
14+
1315
import pytest
1416

1517
from toon_format import ToonDecodeError, decode, encode
@@ -297,9 +299,6 @@ def test_decode_with_json_indent_returns_string(self):
297299
options = DecodeOptions(json_indent=2)
298300
result = decode(toon, options)
299301
assert isinstance(result, str)
300-
# Verify it's valid JSON
301-
import json
302-
303302
parsed = json.loads(result)
304303
assert parsed == {"id": 123, "name": "Alice"}
305304

@@ -351,8 +350,6 @@ def test_decode_json_indent_with_unicode(self):
351350
toon = 'name: "José"'
352351
result = decode(toon, DecodeOptions(json_indent=2))
353352
assert "José" in result
354-
import json
355-
356353
parsed = json.loads(result)
357354
assert parsed["name"] == "José"
358355

@@ -375,8 +372,6 @@ def test_decode_json_indent_complex_nested(self):
375372
version: 1
376373
active: true"""
377374
result = decode(toon, DecodeOptions(json_indent=2))
378-
import json
379-
380375
parsed = json.loads(result)
381376
assert parsed["users"][0] == {"id": 1, "name": "Alice"}
382377
assert parsed["metadata"]["version"] == 1

0 commit comments

Comments
 (0)