summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/format/optionarch.py10
-rw-r--r--tests/format/optionos.py6
-rw-r--r--tests/testutils/__init__.py2
-rw-r--r--tests/testutils/platform.py20
4 files changed, 18 insertions, 20 deletions
diff --git a/tests/format/optionarch.py b/tests/format/optionarch.py
index 3f779e5ea..a7d38c8be 100644
--- a/tests/format/optionarch.py
+++ b/tests/format/optionarch.py
@@ -9,7 +9,7 @@ from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream.plugintestutils.runcli import cli # pylint: disable=unused-import
-from tests.testutils import override_os_uname
+from tests.testutils import override_platform_uname
# Project directory
DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -31,7 +31,7 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
('x86_64', 'aarch64', 'Aarchy'),
])
def test_conditional(cli, datafiles, machine, value, expected):
- with override_os_uname(machine=machine):
+ with override_platform_uname(machine=machine):
project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch')
bst_args = []
@@ -54,7 +54,7 @@ def test_conditional(cli, datafiles, machine, value, expected):
@pytest.mark.datafiles(DATA_DIR)
def test_unsupported_arch(cli, datafiles):
- with override_os_uname(machine="x86_64"):
+ with override_platform_uname(machine="x86_64"):
project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch')
result = cli.run(project=project, silent=True, args=[
'show',
@@ -69,7 +69,7 @@ def test_unsupported_arch(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_alias(cli, datafiles):
- with override_os_uname(machine="arm"):
+ with override_platform_uname(machine="arm"):
project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch-alias')
result = cli.run(project=project, silent=True, args=[
'show',
@@ -84,7 +84,7 @@ def test_alias(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_unknown_host_arch(cli, datafiles):
- with override_os_uname(machine="x86_128"):
+ with override_platform_uname(machine="x86_128"):
project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch')
result = cli.run(project=project, silent=True, args=[
'show',
diff --git a/tests/format/optionos.py b/tests/format/optionos.py
index a4e2a6cf9..6856fd69c 100644
--- a/tests/format/optionos.py
+++ b/tests/format/optionos.py
@@ -9,7 +9,7 @@ from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream.plugintestutils.runcli import cli # pylint: disable=unused-import
-from tests.testutils import override_os_uname
+from tests.testutils import override_platform_uname
DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -30,7 +30,7 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
('HaikuOS', 'SunOS', 'SunOSy'),
])
def test_conditionals(cli, datafiles, system, value, expected):
- with override_os_uname(system=system):
+ with override_platform_uname(system=system):
project = os.path.join(datafiles.dirname, datafiles.basename, 'option-os')
bst_args = []
@@ -53,7 +53,7 @@ def test_conditionals(cli, datafiles, system, value, expected):
@pytest.mark.datafiles(DATA_DIR)
def test_unsupported_arch(cli, datafiles):
- with override_os_uname(system="AIX"):
+ with override_platform_uname(system="AIX"):
project = os.path.join(datafiles.dirname, datafiles.basename, 'option-os')
result = cli.run(project=project, silent=True, args=[
'show',
diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py
index 31912fed9..929ffc5f2 100644
--- a/tests/testutils/__init__.py
+++ b/tests/testutils/__init__.py
@@ -30,4 +30,4 @@ from .junction import generate_junction
from .runner_integration import wait_for_cache_granularity
from .python_repo import setup_pypi_repo
from .yaml import yaml_file_get_provenance
-from .platform import override_os_uname
+from .platform import override_platform_uname
diff --git a/tests/testutils/platform.py b/tests/testutils/platform.py
index e00a131bd..f8faf286e 100644
--- a/tests/testutils/platform.py
+++ b/tests/testutils/platform.py
@@ -18,34 +18,32 @@
# Angelos Evripiotis <jevripiotis@bloomberg.net>
from contextlib import contextmanager
-import os
+import platform
# override_platform_uname()
#
-# Context manager to override the reported value of `os.uname()`.
+# Context manager to override the reported value of `platform.uname()`.
#
# Args:
# system (str): Optional str to replace the 1st entry of uname with.
# machine (str): Optional str to replace the 5th entry of uname with.
#
@contextmanager
-def override_os_uname(*, system=None, machine=None):
- orig_func = os.uname
- result = orig_func()
+def override_platform_uname(*, system=None, machine=None):
+ orig_func = platform.uname
+ result = platform.uname()
- result = list(result)
if system is not None:
- result[0] = system
+ result = result._replace(system=system)
if machine is not None:
- result[4] = machine
- result = tuple(result)
+ result = result._replace(machine=machine)
def override_func():
return result
- os.uname = override_func
+ platform.uname = override_func
try:
yield
finally:
- os.uname = orig_func
+ platform.uname = orig_func