def test_print_versions_no_path(): path = os.environ["PATH"] os.environ["PATH"] = "xxx" try: eq_(proc("pyscreenshot.check.versions").return_code, 0) finally: os.environ["PATH"] = path
def childprocess_backend_version_popen(backend): p = proc("pyscreenshot.cli.print_backend_version", [backend]) if p.return_code != 0: log.error(p) raise FailedBackendError(p) return p.stdout
def run_all(n, childprocess, virtual_only=True): print("") print("n=%s" % n) print("------------------------------------------------------") for x in pyscreenshot.backends(): if virtual_only and x == "gnome-screenshot": continue if childprocess: try: run(x, n, True) except pyscreenshot.FailedBackendError: pass else: p = proc("pyscreenshot.check.speedtest", ["--backend", x]) print(p.stdout)
def childprocess_grab_popen(backend, bbox): if not backend: backend = "" if not bbox: bbox = (0, 0, 0, 0) x1, y1, x2, y2 = map(str, bbox) with TemporaryDirectory(prefix="pyscreenshot") as tmpdirname: filename = os.path.join(tmpdirname, "screenshot.png") p = proc( "pyscreenshot.cli.grab_to_file", [filename, x1, y1, x2, y2, "--backend", backend], ) if p.return_code != 0: # log.debug(p) raise FailedBackendError(p) data = open(filename, "rb").read() data = codec[1](data) return data
def test_showgrabfullscreen(): eq_(proc("pyscreenshot.examples.showgrabfullscreen").return_code, 0)
def test_showgrabbox(): eq_(proc("pyscreenshot.examples.showgrabbox").return_code, 0)
def test_speedtest(): eq_( proc("pyscreenshot.check.speedtest", ["--childprocess"]).return_code, 0) eq_(proc("pyscreenshot.check.speedtest").return_code, 0)
def test_print_versions(): eq_(proc("pyscreenshot.check.versions").return_code, 0)