From 63ada3ee6283cc7e346494070799fe07fe360fa9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 6 Nov 2024 12:55:31 -0800 Subject: [PATCH] tests: functional: Don't enable/disable app during tests - Currently, after every test we disable the app and re-enable for the next test. The original purpose of this disabling is to make sure that an app is disabled after test on it. So, change the scope of disabling the app to ensure that it is only disabled once after all the tests on the app. This should improve the run time of the tests. Tests: - Run functional tests on bepasty app. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/tests/functional/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 40f7f7cff..af6a1ca8a 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -738,16 +738,21 @@ class BaseAppTests: """Install the app and set it up if needed.""" install(session_browser, self.app_name) + @pytest.fixture(autouse=True, scope='class', name='disable_after_tests') + def fixture_disable_after_tests(self, session_browser): + """Disable the app after running tests.""" + yield + if self.disable_after_tests: + app_disable(session_browser, self.app_name) + @pytest.fixture(autouse=True, name='background') - def fixture_background(self, session_browser): + def fixture_background(self, session_browser, disable_after_tests): """Login, install, and enable the app.""" login(session_browser) self.install_and_setup(session_browser) app_enable(session_browser, self.app_name) yield login(session_browser) - if self.disable_after_tests: - app_disable(session_browser, self.app_name) def test_enable_disable(self, session_browser): """Test enabling and disabling the app."""