diff --git a/src/tests/test_implementation.py b/src/tests/test_implementation.py index 7dc8851e..53762427 100644 --- a/src/tests/test_implementation.py +++ b/src/tests/test_implementation.py @@ -250,7 +250,11 @@ def test_output_pattern_with_date(self, with_cursor: bool, capsys: pytest.Captur @pytest.mark.parametrize("coordinates", ["2,12,40,67", "40x67+12+2"]) def test_coordinates_capture(self, with_cursor: bool, capsys: pytest.CaptureFixture, coordinates: str) -> None: - filename = Path("sct-2x12_40x67.png") + # Coordinates are relative to the selected monitor (monitor 0 by default: the whole virtual screen), whose + # origin is not 0,0 when a monitor sits left of or above the primary one. + with mss.MSS() as sct: + origin = sct.monitors[0] + filename = Path(f"sct-{origin.top + 2}x{origin.left + 12}_40x67.png") for opt in ("-c", "--coordinates"): self._run_main(with_cursor, opt, coordinates) captured = capsys.readouterr() diff --git a/src/tests/test_save.py b/src/tests/test_save.py index 8457cefe..7f824df9 100644 --- a/src/tests/test_save.py +++ b/src/tests/test_save.py @@ -39,7 +39,8 @@ def test_callback(mss_impl: Callable[..., MSS]) -> None: def on_exists(fname: str) -> None: file = Path(fname) if Path(file).is_file(): - file.rename(f"{file.name}.old") + # replace() overwrites a leftover .old file on every OS; rename() raises FileExistsError on Windows. + file.replace(f"{file.name}.old") with mss_impl() as sct: filename = sct.shot(mon=0, output="mon0.png", callback=on_exists)