diff --git a/plinth/modules/storage/tests/test_functional.py b/plinth/modules/storage/tests/test_functional.py index cdfc085c1..d0dd20bfb 100644 --- a/plinth/modules/storage/tests/test_functional.py +++ b/plinth/modules/storage/tests/test_functional.py @@ -3,6 +3,7 @@ Functional, browser based tests for storage app. """ import pytest + from plinth.tests import functional pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.storage] @@ -16,7 +17,7 @@ def fixture_background(session_browser): def test_list_disks(session_browser): """Test that root disk is shown on storage page.""" - if functional.running_inside_container: + if functional.running_inside_container(): pytest.skip('Storage doesn\'t work inside a container') else: functional.nav_to_module(session_browser, 'storage') diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index d8927acae..e162f4021 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -439,9 +439,17 @@ def service_is_not_running(browser, app_name): def running_inside_container(): """Check if freedombox is running inside a container""" + # If the URL to connect to was overridden then assume that we are running + # tests on a different machine than the machine running freedombox. Assume + # running inside container to be conservative about tests. + if config['DEFAULT']['url'] != 'https://localhost': + return True + + # If URL is not overridden then testing code and freedombox are running on + # the same machine. Proceed with a proper test. result = subprocess.run(['systemd-detect-virt', '--container'], - stdout=subprocess.PIPE) - return bool(result.stdout.decode('utf-8').lower() != "none\n") + stdout=subprocess.PIPE, check=False) + return result.stdout.decode('utf-8').strip().lower() != 'none' ##############################