File tree Expand file tree Collapse file tree 3 files changed +14
-17
lines changed Expand file tree Collapse file tree 3 files changed +14
-17
lines changed Original file line number Diff line number Diff line change 11"""Tools conftest"""
22
33import json
4- import os
5- from pathlib import Path
64import pytest
75
8-
9- def get_results_dir_path ():
10- """Method that gives you the path to the directory where you should store test results."""
11- try :
12- results_dir = os .environ .get ("resultsdir" )
13- return Path (results_dir )
14- except KeyError :
15- current_file = Path (__file__ ).resolve ()
16- project_dir = current_file .parents [3 ]
17- return project_dir / "attachments"
6+ from testsuite .utils import get_results_dir_path
187
198
209def save_as_json (data , path ):
@@ -34,5 +23,6 @@ def save_as_json(data, path):
3423@pytest .hookimpl (trylast = True )
3524def pytest_metadata (metadata ):
3625 """Saves metadata to the attachments directory in json format"""
26+ # path to resultsdir folder defaults to root of testsuite repository
3727 results_dir_path = get_results_dir_path ()
38- save_as_json (metadata , results_dir_path / "pytest_metadata.json" )
28+ save_as_json (metadata , results_dir_path / "attachments" / " pytest_metadata.json" )
Original file line number Diff line number Diff line change 3333from testsuite .ui .views .master .audience .tenant import TenantNewView , TenantDetailView
3434from testsuite .ui .views .master .login import MasterLoginView
3535from testsuite .ui .webdriver import ThreescaleWebdriver
36- from testsuite .utils import blame
36+ from testsuite .utils import blame , get_results_dir_path
3737
3838
3939LOGGER = logging .getLogger (__name__ )
@@ -448,12 +448,11 @@ def get_resultsdir_path(node):
448448 """
449449
450450 xml = node .config .getoption ("--junitxml" )
451- # path to "3scape-py-testsuite" folder
452- no_argument_dir = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "../../.." )
453- resultsdir = os .environ .get ("resultsdir" , no_argument_dir )
454451 failed_test_name = node .nodeid .replace ("/" , "." ).replace (".py::" , "." )
455452
456453 if not xml :
454+ # path to resultsdir folder defaults to root of testsuite repository
455+ resultsdir = get_results_dir_path ()
457456 path = f"{ resultsdir } /attachments/ui/{ failed_test_name } /"
458457
459458 else :
Original file line number Diff line number Diff line change 88import warnings
99from base64 import b64encode
1010from os import urandom
11+ from pathlib import Path
1112
1213import pytest
1314
@@ -229,3 +230,10 @@ def custom_policy() -> dict:
229230 return _M
230231 """
231232 return {"init.lua" : initlua , "example.lua" : examplelua , "apicast-policy.json" : apicastpolicyjson }
233+
234+
235+ def get_results_dir_path ():
236+ """resolve resultsdir or defaults to root of 3scale-tests repo"""
237+ no_argument_dir = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "../../.." )
238+ resultsdir = os .environ .get ("resultsdir" , no_argument_dir )
239+ return Path (resultsdir )
You can’t perform that action at this time.
0 commit comments