From f62ce2f793e577a66f14eab09e4e27b6db35690f Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 24 Jan 2023 13:24:45 +0100 Subject: [PATCH] refactor(tests): always use screen_recording context manager and have it not record internally when appropriate --- tests/conftest.py | 5 +---- tests/ui_tests/__init__.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a4f70101f3..fbea5c7954 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -226,10 +226,7 @@ def client( _raw_client.clear_session() - if test_ui: - with ui_tests.screen_recording(_raw_client, request): - yield _raw_client - else: + with ui_tests.screen_recording(_raw_client, request): yield _raw_client _raw_client.close() diff --git a/tests/ui_tests/__init__.py b/tests/ui_tests/__init__.py index fe2d1be73f..9bcf543b6f 100644 --- a/tests/ui_tests/__init__.py +++ b/tests/ui_tests/__init__.py @@ -127,6 +127,10 @@ def screen_recording( client: Client, request: pytest.FixtureRequest ) -> Generator[None, None, None]: test_ui = request.config.getoption("ui") + if not test_ui: + yield + return + test_name = get_test_name(request.node.nodeid) # Differentiating test names between T1 and TT @@ -160,15 +164,14 @@ def screen_recording( client.init_device() client.debug.stop_recording() - if test_ui: - PROCESSED.add(test_name) - if get_last_call_test_result(request) is False: - FAILED_TESTS.add(test_name) + PROCESSED.add(test_name) + if get_last_call_test_result(request) is False: + FAILED_TESTS.add(test_name) - if test_ui == "record": - _process_recorded(screen_path, test_name) - else: - _process_tested(screens_test_path, test_name) + if test_ui == "record": + _process_recorded(screen_path, test_name) + else: + _process_tested(screens_test_path, test_name) def list_missing() -> Set[str]: