chore: screenshot on fail improved

This commit is contained in:
Anastasiya Semenkevich 2024-03-06 18:05:02 +03:00 committed by Anastasiya
parent 0848301498
commit 39445afd89
4 changed files with 6 additions and 10 deletions

2
test/e2e/.gitignore vendored
View File

@ -10,4 +10,4 @@ tmp/
*.DS_Store
/local run results/
/local_run_results/

View File

@ -13,7 +13,7 @@ TEST_ARTIFACTS: typing.Optional[SystemPath] = None
# Test Directories
RUN_ID = os.getenv('RUN_DIR', f'run_{datetime.today().strftime("%Y-%m-%d %H:%M:%S")}')
RESULTS: SystemPath = ROOT / 'local run results'
RESULTS: SystemPath = ROOT / 'local_run_results'
RUN: SystemPath = RESULTS / RUN_ID
VP: SystemPath = ROOT / 'ext' / 'vp'
TEST_FILES: SystemPath = ROOT / 'ext' / 'test_files'

View File

@ -42,8 +42,7 @@ def setup_session_scope(
def setup_function_scope(
caplog,
generate_test_data,
check_result,
application_logs
check_result
):
# FIXME: broken due to KeyError: <_pytest.stash.StashKey object at 0x7fd1ba6d78c0>
# caplog.set_level(configs.LOG_LEVEL)
@ -61,10 +60,7 @@ def pytest_exception_interact(node):
test_path, test_name, test_params = generate_test_info(node)
node_dir: SystemPath = configs.testpath.RUN / test_path / test_name / test_params
node_dir.mkdir(parents=True, exist_ok=True)
screenshot = node_dir / 'screenshot.png'
if screenshot.exists():
screenshot = node_dir / f'screenshot_{datetime.now():%H%M%S}.png'
screenshot = node_dir / f'screenshot_{datetime.today().strftime("%Y-%m-%d %H:%M:%S")}.png'
ImageGrab.grab(xdisplay=configs.system.DISPLAY if IS_LIN else None).save(screenshot)
allure.attach(
name='Screenshot on fail',

View File

@ -64,7 +64,7 @@ class AUT:
body=screenshot.read_bytes(),
attachment_type=allure.attachment_type.PNG)
except Exception as err:
LOG.info(err)
LOG.error(err)
self.stop()