Fix line length issues in IF session tests
This commit is contained in:
parent
76488139c8
commit
43fce6a4ed
2 changed files with 10 additions and 4 deletions
|
|
@ -36,7 +36,7 @@ class IFSession:
|
||||||
"""Return path to save file for this player/game combo."""
|
"""Return path to save file for this player/game combo."""
|
||||||
# Sanitize player name to prevent path traversal attacks
|
# Sanitize player name to prevent path traversal attacks
|
||||||
# Account creation doesn't validate names, so defensive check here
|
# Account creation doesn't validate names, so defensive check here
|
||||||
safe_name = re.sub(r'[^a-zA-Z0-9_-]', '_', self.player.name)
|
safe_name = re.sub(r"[^a-zA-Z0-9_-]", "_", self.player.name)
|
||||||
return self._data_dir / "if_saves" / safe_name / f"{self.game_name}.qzl"
|
return self._data_dir / "if_saves" / safe_name / f"{self.game_name}.qzl"
|
||||||
|
|
||||||
def _ensure_save_dir(self) -> None:
|
def _ensure_save_dir(self) -> None:
|
||||||
|
|
|
||||||
|
|
@ -617,7 +617,9 @@ async def test_quit_then_stop_does_not_double_save(tmp_path):
|
||||||
|
|
||||||
# Verify save was called once
|
# Verify save was called once
|
||||||
save_calls = [
|
save_calls = [
|
||||||
call for call in mock_process.stdin.write.call_args_list if call[0][0] == b"save\n"
|
call
|
||||||
|
for call in mock_process.stdin.write.call_args_list
|
||||||
|
if call[0][0] == b"save\n"
|
||||||
]
|
]
|
||||||
assert len(save_calls) == 1
|
assert len(save_calls) == 1
|
||||||
|
|
||||||
|
|
@ -626,7 +628,9 @@ async def test_quit_then_stop_does_not_double_save(tmp_path):
|
||||||
|
|
||||||
# Verify save was still only called once
|
# Verify save was still only called once
|
||||||
save_calls = [
|
save_calls = [
|
||||||
call for call in mock_process.stdin.write.call_args_list if call[0][0] == b"save\n"
|
call
|
||||||
|
for call in mock_process.stdin.write.call_args_list
|
||||||
|
if call[0][0] == b"save\n"
|
||||||
]
|
]
|
||||||
assert len(save_calls) == 1, "stop() should not save again after ::quit"
|
assert len(save_calls) == 1, "stop() should not save again after ::quit"
|
||||||
mock_process.terminate.assert_called_once()
|
mock_process.terminate.assert_called_once()
|
||||||
|
|
@ -680,7 +684,9 @@ async def test_regular_input_resets_save_flag(tmp_path):
|
||||||
|
|
||||||
# Verify save was called twice
|
# Verify save was called twice
|
||||||
save_calls = [
|
save_calls = [
|
||||||
call for call in mock_process.stdin.write.call_args_list if call[0][0] == b"save\n"
|
call
|
||||||
|
for call in mock_process.stdin.write.call_args_list
|
||||||
|
if call[0][0] == b"save\n"
|
||||||
]
|
]
|
||||||
assert len(save_calls) == 2, "should be able to save again after regular input"
|
assert len(save_calls) == 2, "should be able to save again after regular input"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue