def test_entry_point(capsys, sct): from mss.__main__ import main from datetime import datetime for opt in ("-m", "--monitor"): main([opt, "1"]) out, _ = capsys.readouterr() assert out.endswith("monitor-1.png\n") assert os.path.isfile("monitor-1.png") os.remove("monitor-1.png") for opt in zip(("-m 1", "--monitor=1"), ("-q", "--quiet")): main(opt) out, _ = capsys.readouterr() assert not out assert os.path.isfile("monitor-1.png") os.remove("monitor-1.png") fmt = "sct-{width}x{height}.png" for opt in ("-o", "--out"): main([opt, fmt]) filename = fmt.format(**sct.monitors[1]) out, _ = capsys.readouterr() assert out.endswith(filename + "\n") assert os.path.isfile(filename) os.remove(filename) fmt = "sct_{mon}-{date:%Y-%m-%d}.png" for opt in ("-o", "--out"): main(["-m 1", opt, fmt]) filename = fmt.format(mon=1, date=datetime.now()) out, _ = capsys.readouterr() assert out.endswith(filename + "\n") assert os.path.isfile(filename) os.remove(filename) coordinates = "2,12,40,67" for opt in ("-c", "--coordinates"): main([opt, coordinates]) filename = "sct-2x12_40x67.png" out, _ = capsys.readouterr() assert out.endswith(filename + "\n") assert os.path.isfile(filename) os.remove(filename) coordinates = "2,12,40" for opt in ("-c", "--coordinates"): main([opt, coordinates]) out, _ = capsys.readouterr() assert out == "Coordinates syntax: top, left, width, height\n"
def test_entry_point(capsys, sct): from mss.__main__ import main from datetime import datetime for opt in ("-m", "--monitor"): main([opt, "1"]) out, _ = capsys.readouterr() assert out.endswith("monitor-1.png\n") assert os.path.isfile("monitor-1.png") os.remove("monitor-1.png") for opt in zip(("-m 1", "--monitor=1"), ("-q", "--quiet")): main(opt) out, _ = capsys.readouterr() assert not out assert os.path.isfile("monitor-1.png") os.remove("monitor-1.png") fmt = "sct-{width}x{height}.png" for opt in ("-o", "--out"): main([opt, fmt]) out, _ = capsys.readouterr() for monitor, line in zip(sct.monitors[1:], out.splitlines()): filename = fmt.format(**monitor) assert line.endswith(filename) assert os.path.isfile(filename) os.remove(filename) fmt = "sct_{mon}-{date:%Y-%m-%d}.png" for opt in ("-o", "--out"): main(["-m 1", opt, fmt]) filename = fmt.format(mon=1, date=datetime.now()) out, _ = capsys.readouterr() assert out.endswith(filename + "\n") assert os.path.isfile(filename) os.remove(filename) coordinates = "2,12,40,67" for opt in ("-c", "--coordinates"): main([opt, coordinates]) filename = "sct-2x12_40x67.png" out, _ = capsys.readouterr() assert out.endswith(filename + "\n") assert os.path.isfile(filename) os.remove(filename) coordinates = "2,12,40" for opt in ("-c", "--coordinates"): main([opt, coordinates]) out, _ = capsys.readouterr() assert out == "Coordinates syntax: top, left, width, height\n"
def test_entry_point(capsys, sct): from mss.__main__ import main from datetime import datetime for opt in ('-m', '--monitor'): main([opt, '1']) out, _ = capsys.readouterr() assert out.endswith('monitor-1.png\n') assert os.path.isfile('monitor-1.png') os.remove('monitor-1.png') for opt in zip(('-m 1', '--monitor=1'), ('-q', '--quiet')): main(opt) out, _ = capsys.readouterr() assert not out assert os.path.isfile('monitor-1.png') os.remove('monitor-1.png') fmt = 'sct-{width}x{height}.png' for opt in ('-o', '--out'): main([opt, fmt]) filename = fmt.format(**sct.monitors[1]) out, _ = capsys.readouterr() assert out.endswith(filename + '\n') assert os.path.isfile(filename) os.remove(filename) fmt = 'sct_{mon}-{date:%Y-%m-%d}.png' for opt in ('-o', '--out'): main([opt, fmt]) filename = fmt.format(mon=1, date=datetime.now()) out, _ = capsys.readouterr() assert out.endswith(filename + '\n') assert os.path.isfile(filename) os.remove(filename) coordinates = '2,12,40,67' for opt in ('-c', '--coordinates'): main([opt, coordinates]) filename = 'sct-2x12_40x67.png' out, _ = capsys.readouterr() assert out.endswith(filename + '\n') assert os.path.isfile(filename) os.remove(filename) coordinates = '2,12,40' for opt in ('-c', '--coordinates'): main([opt, coordinates]) out, _ = capsys.readouterr() assert out == 'Coordinates syntax: top, left, width, height\n'