Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/tests/test_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading