11import pytest
22import os
3+ import sys
34import subprocess
45import shlex
6+ import hashlib
57from inspect import getmembers , isfunction
68from allure_commons_test .report import AllureReport
79from allure_commons .utils import thread_tag
810
911
12+ def _get_hash (input ):
13+ if sys .version_info < (3 , 0 ):
14+ data = bytes (input )
15+ else :
16+ data = bytes (input , 'utf8' )
17+ return hashlib .md5 (data ).hexdigest ()
18+
19+
1020@pytest .fixture (scope = 'function' , autouse = True )
1121def inject_matchers (doctest_namespace ):
1222 import hamcrest
@@ -22,7 +32,8 @@ def inject_matchers(doctest_namespace):
2232def _runner (allure_dir , module , * extra_params ):
2333 FNULL = open (os .devnull , 'w' )
2434 extra_params = ' ' .join (extra_params )
25- cmd = shlex .split ('pytest --alluredir=%s %s %s' % (allure_dir , extra_params , module ))
35+ cmd = shlex .split ('pytest --alluredir=%s %s %s' % (allure_dir , extra_params , module ),
36+ posix = False if os .name == "nt" else True )
2637 subprocess .call (cmd , stdout = FNULL , stderr = FNULL )
2738
2839
@@ -32,7 +43,7 @@ def allure_report_with_params(request, tmpdir_factory):
3243 tmpdir = tmpdir_factory .mktemp ('data' )
3344
3445 def run_with_params (* params ):
35- key = '{thread}{module}{param}' .format (thread = thread_tag (), module = module , param = '' .join (params ))
46+ key = _get_hash ( '{thread}{module}{param}' .format (thread = thread_tag (), module = module , param = '' .join (params ) ))
3647 if not request .config .cache .get (key , False ):
3748 _runner (tmpdir .strpath , module , * params )
3849 request .config .cache .set (key , True )
0 commit comments