summaryrefslogtreecommitdiff
path: root/tests/helpers/fixtures.py
diff options
context:
space:
mode:
authorAxel Dahlberg <axel.dahlberg12@gmail.com>2021-01-15 18:06:14 +0100
committerAxel Dahlberg <axel.dahlberg12@gmail.com>2021-01-15 18:06:14 +0100
commit3051f684f7a8353183a9b476c5a584daf84b6da5 (patch)
treee4c3d07ef865fa9de95ff0bbb10f27340763add3 /tests/helpers/fixtures.py
parentaa542e7ed32e58289f8b50f4847a4bfa0ebd3571 (diff)
downloadqutebrowser-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.py10
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