Skip to content

Commit ca105cb

Browse files
Sup3rGeosseliverstov
authored andcommitted
improve test running and debugging (via #231)
1 parent af87869 commit ca105cb

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

allure-pytest/test/conftest.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import pytest
23
import os
34
import sys
@@ -9,6 +10,11 @@
910
from allure_commons.utils import thread_tag
1011

1112

13+
with open("debug-runner", "w") as debugfile:
14+
# overwrite debug-runner file with an empty one
15+
print("New session", file=debugfile)
16+
17+
1218
def _get_hash(input):
1319
if sys.version_info < (3, 0):
1420
data = bytes(input)
@@ -30,11 +36,15 @@ def inject_matchers(doctest_namespace):
3036

3137

3238
def _runner(allure_dir, module, *extra_params):
33-
FNULL = open(os.devnull, 'w')
3439
extra_params = ' '.join(extra_params)
35-
cmd = shlex.split('pytest --alluredir=%s %s %s' % (allure_dir, extra_params, module),
40+
cmd = shlex.split('%s -m pytest --alluredir=%s %s %s' % (sys.executable, allure_dir, extra_params, module),
3641
posix=False if os.name == "nt" else True)
37-
subprocess.call(cmd, stdout=FNULL, stderr=FNULL)
42+
with open("debug-runner", "a") as debugfile:
43+
try:
44+
subprocess.check_output(cmd, stderr = subprocess.STDOUT)
45+
except subprocess.CalledProcessError as e:
46+
# Save to debug file errors on execution (includes pytest failing tests)
47+
print(e.output, file=debugfile)
3848

3949

4050
@pytest.fixture(scope='module')

0 commit comments

Comments
 (0)