diff options
author | Axel Dahlberg <axel.dahlberg12@gmail.com> | 2021-01-15 18:06:14 +0100 |
---|---|---|
committer | Axel Dahlberg <axel.dahlberg12@gmail.com> | 2021-01-15 18:06:14 +0100 |
commit | 3051f684f7a8353183a9b476c5a584daf84b6da5 (patch) | |
tree | e4c3d07ef865fa9de95ff0bbb10f27340763add3 /tests/helpers/fixtures.py | |
parent | aa542e7ed32e58289f8b50f4847a4bfa0ebd3571 (diff) | |
download | qutebrowser-3051f684f7a8353183a9b476c5a584daf84b6da5.tar.gz qutebrowser-3051f684f7a8353183a9b476c5a584daf84b6da5.zip |
using tmp-file for py_proc fixture
Diffstat (limited to 'tests/helpers/fixtures.py')
-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 b814a6ea7..7042a39f5 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 |