Skip to content

Commit 3665973

Browse files
committed
Fix linting errors in test suite
1 parent c571ab7 commit 3665973

11 files changed

+18
-23
lines changed

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
This module provides reusable test data and fixtures following pytest best practices.
44
"""
55

6-
import pytest
76
from typing import Any, Dict, List
87

8+
import pytest
9+
910

1011
# Simple test data fixtures
1112
@pytest.fixture

tests/test_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
"""
1212

1313
import pytest
14-
from toon_format import encode, decode, ToonDecodeError
15-
from toon_format.types import EncodeOptions, DecodeOptions
14+
15+
from toon_format import ToonDecodeError, decode, encode
16+
from toon_format.types import DecodeOptions, EncodeOptions
1617

1718

1819
class TestEncodeAPI:

tests/test_cli.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""Integration tests for the CLI module."""
22

33
import json
4-
import sys
54
from io import StringIO
6-
from pathlib import Path
75
from unittest.mock import MagicMock, patch
86

97
import pytest
@@ -239,7 +237,7 @@ def test_custom_delimiter_option(self, tmp_path):
239237
input_file = tmp_path / "input.json"
240238
input_file.write_text('{"items": [1, 2, 3]}')
241239

242-
with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
240+
with patch("sys.stdout", new_callable=StringIO):
243241
with patch("sys.argv", ["toon", str(input_file), "--encode", "--delimiter", "|"]):
244242
result = main()
245243
assert result == 0
@@ -249,7 +247,7 @@ def test_custom_indent_option(self, tmp_path):
249247
input_file = tmp_path / "input.json"
250248
input_file.write_text('{"outer": {"inner": 1}}')
251249

252-
with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
250+
with patch("sys.stdout", new_callable=StringIO):
253251
with patch("sys.argv", ["toon", str(input_file), "--encode", "--indent", "4"]):
254252
result = main()
255253
assert result == 0
@@ -259,7 +257,7 @@ def test_length_marker_option(self, tmp_path):
259257
input_file = tmp_path / "input.json"
260258
input_file.write_text('{"items": [1, 2, 3]}')
261259

262-
with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
260+
with patch("sys.stdout", new_callable=StringIO):
263261
with patch("sys.argv", ["toon", str(input_file), "--encode", "--length-marker"]):
264262
result = main()
265263
assert result == 0
@@ -269,7 +267,7 @@ def test_no_strict_option(self, tmp_path):
269267
input_file = tmp_path / "input.toon"
270268
input_file.write_text("name: Test")
271269

272-
with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
270+
with patch("sys.stdout", new_callable=StringIO):
273271
with patch("sys.argv", ["toon", str(input_file), "--decode", "--no-strict"]):
274272
result = main()
275273
assert result == 0
@@ -307,7 +305,7 @@ def test_error_during_encoding(self, tmp_path):
307305
def test_error_reading_input(self):
308306
"""Test error when reading input fails."""
309307
mock_stdin = MagicMock()
310-
mock_stdin.read.side_effect = IOError("Read failed")
308+
mock_stdin.read.side_effect = OSError("Read failed")
311309

312310
with patch("sys.stdin", mock_stdin):
313311
with patch("sys.stderr", new_callable=StringIO) as mock_stderr:

tests/test_decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ def test_decode_returns_python_dict(self):
3939
toon = "id: 123"
4040
result = decode(toon)
4141
assert isinstance(result, dict)
42-
assert type(result) == dict # Not a subclass
42+
assert type(result) is dict # Not a subclass
4343

4444
def test_decode_returns_python_list(self):
4545
"""Ensure decode returns native Python list for arrays."""
4646
toon = "[3]: 1,2,3"
4747
result = decode(toon)
4848
assert isinstance(result, list)
49-
assert type(result) == list # Not a subclass
49+
assert type(result) is list # Not a subclass
5050

5151

5252
class TestPythonErrorHandling:

tests/test_encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_encode_returns_python_str(self):
3030
"""Ensure encode returns native Python str, not bytes or custom type."""
3131
result = encode({"id": 123})
3232
assert isinstance(result, str)
33-
assert type(result) == str # Not a subclass
33+
assert type(result) is str # Not a subclass
3434

3535
def test_encode_handles_none_gracefully(self):
3636
"""Test encoding None doesn't crash (Python-specific edge case)."""

tests/test_internationalization.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
TOON specification Section 16 (Internationalization).
55
"""
66

7-
import pytest
87

98
from toon_format import decode, encode
109

tests/test_normalization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
official fixtures from https://github.com/toon-format/spec
1717
"""
1818

19-
import pytest
2019
from decimal import Decimal
20+
2121
from toon_format import decode, encode
2222

2323

tests/test_normalize_functions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
full coverage of edge cases and error paths.
55
"""
66

7-
import sys
8-
from collections import OrderedDict, UserDict
7+
from collections import OrderedDict
98
from datetime import date, datetime
109
from decimal import Decimal
11-
from unittest.mock import MagicMock
1210

1311
import pytest
1412

tests/test_parsing_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,5 @@ def test_realistic_tabular_row_detection(self):
327327

328328
# Row with quoted field containing colon
329329
row_with_quote = 'Alice,"30:manager",Engineer'
330-
first_comma = find_unquoted_char(row_with_quote, ",")
331330
first_colon = find_unquoted_char(row_with_quote, ":")
332331
assert first_colon == -1 # Colon only in quotes = row

tests/test_security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from the TOON specification Section 15.
55
"""
66

7+
78
import pytest
8-
import sys
99

1010
from toon_format import decode, encode
1111
from toon_format.types import DecodeOptions

0 commit comments

Comments
 (0)