diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-01-19 13:37:14 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-01-19 13:37:14 +0100 |
commit | 0f8f52782ce5e4c4a57fba493760736adebf13b3 (patch) | |
tree | 5d8b5cf77b934cbbf86eeeada472569b121c1b42 /tests/helpers | |
parent | d45b68a98dcd169b23087becacacea9790097849 (diff) | |
parent | 2d6d1dad4309aaaebdcb608bb46445fd62343a37 (diff) | |
download | qutebrowser-0f8f52782ce5e4c4a57fba493760736adebf13b3.tar.gz qutebrowser-0f8f52782ce5e4c4a57fba493760736adebf13b3.zip |
Merge remote-tracking branch 'origin/pr/5987'
Diffstat (limited to 'tests/helpers')
-rw-r--r-- | tests/helpers/fixtures.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 2d853df08..7de34a9a7 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -503,13 +503,19 @@ def cookiejar_and_cache(stubs, monkeypatch): @pytest.fixture -def py_proc(): +def py_proc(tmp_path): """Get a python executable and args list which executes the given code.""" if getattr(sys, 'frozen', False): pytest.skip("Can't be run when frozen") def func(code): - return (sys.executable, ['-c', textwrap.dedent(code.strip('\n'))]) + code = textwrap.dedent(code.strip('\n')) + if '\n' in code: + py_file = tmp_path / 'py_proc.py' + py_file.write_text(code) + return (sys.executable, [str(py_file)]) + else: + return (sys.executable, ['-c', code]) return func |