11"""Integration tests for the CLI module."""
22
33import json
4- import sys
54from io import StringIO
6- from pathlib import Path
75from unittest .mock import MagicMock , patch
86
97import 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 :
0 commit comments