diff -Nru pytest-salt-factories-0.907.0/debian/changelog pytest-salt-factories-0.907.0/debian/changelog --- pytest-salt-factories-0.907.0/debian/changelog 2021-11-03 10:58:11.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/changelog 2022-04-15 22:27:58.000000000 +0000 @@ -1,3 +1,14 @@ +pytest-salt-factories (0.907.0-4) unstable; urgency=medium + + * Update my email address to @debian.org + * Update year in debian/copyright + * Switch to pytest-skip-markers to avoid breaking pytest if both + pytest-skip-markers and pytest-salt-factories are installed. + * Do not run test cases during package build and only rely on autopkgtest + because the test suite relies on salt and introduces a circular dependency. + + -- Benjamin Drung Sat, 16 Apr 2022 00:27:58 +0200 + pytest-salt-factories (0.907.0-3) unstable; urgency=medium * Mock network access in test_has_remote_network diff -Nru pytest-salt-factories-0.907.0/debian/control pytest-salt-factories-0.907.0/debian/control --- pytest-salt-factories-0.907.0/debian/control 2021-10-26 17:04:29.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/control 2022-04-15 22:25:19.000000000 +0000 @@ -1,23 +1,13 @@ Source: pytest-salt-factories Maintainer: Debian Salt Team -Uploaders: Benjamin Drung +Uploaders: Benjamin Drung Section: python Priority: optional Build-Depends: debhelper-compat (= 13), dh-python, - openssh-server, python3, - python3-msgpack (>= 0.5.6), - python3-pip, - python3-psutil (>= 4.2.0), - python3-pytest (>= 6), - python3-pytest-helpers-namespace (>= 2021.4.29), - python3-pytest-subtests, - python3-pytest-tempdir (>= 2019.9.16), python3-setuptools (>= 50.3.2), - python3-setuptools-scm (>= 3.4), - python3-zmq, - salt-common + python3-setuptools-scm (>= 3.4) Rules-Requires-Root: no Standards-Version: 4.6.0 Homepage: https://github.com/saltstack/pytest-salt-factories @@ -30,6 +20,7 @@ python3-psutil (>= 4.2.0), python3-pytest (>= 4.6.6), python3-pytest-helpers-namespace (>= 2021.4.29), + python3-pytest-skip-markers, python3-pytest-tempdir (>= 2019.9.16), python3-zmq, ${misc:Depends}, diff -Nru pytest-salt-factories-0.907.0/debian/copyright pytest-salt-factories-0.907.0/debian/copyright --- pytest-salt-factories-0.907.0/debian/copyright 2021-05-03 15:06:56.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/copyright 2022-04-15 22:04:28.000000000 +0000 @@ -6,7 +6,7 @@ License: Apache-2.0 Files: debian/* -Copyright: 2020-2021 Benjamin Drung +Copyright: 2020-2022 Benjamin Drung License: Apache-2.0 License: Apache-2.0 diff -Nru pytest-salt-factories-0.907.0/debian/gbp.conf pytest-salt-factories-0.907.0/debian/gbp.conf --- pytest-salt-factories-0.907.0/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/gbp.conf 2022-04-15 22:04:28.000000000 +0000 @@ -0,0 +1,6 @@ +[DEFAULT] +debian-branch = debian/unstable +pristine-tar = True + +[pq] +patch-numbers = False diff -Nru pytest-salt-factories-0.907.0/debian/patches/Drop-setuptools-declarative-requirements.patch pytest-salt-factories-0.907.0/debian/patches/Drop-setuptools-declarative-requirements.patch --- pytest-salt-factories-0.907.0/debian/patches/Drop-setuptools-declarative-requirements.patch 2021-10-26 16:34:46.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/patches/Drop-setuptools-declarative-requirements.patch 2022-04-15 22:05:06.000000000 +0000 @@ -1,4 +1,3 @@ -From 75821e6b70b379237a55b8e42fed1a7fd84d9507 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Wed, 28 Apr 2021 13:44:50 +0200 Subject: Drop setuptools-declarative-requirements @@ -16,7 +15,7 @@ 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg -index 2176f2e..e3920c0 100644 +index 170db30..49fe31d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,6 @@ python_requires = >= 3.5 @@ -27,6 +26,3 @@ [options.packages.find] where = src --- -2.27.0 - diff -Nru pytest-salt-factories-0.907.0/debian/patches/Fix-test_has_local_network-if-local-network-is-not-p.patch pytest-salt-factories-0.907.0/debian/patches/Fix-test_has_local_network-if-local-network-is-not-p.patch --- pytest-salt-factories-0.907.0/debian/patches/Fix-test_has_local_network-if-local-network-is-not-p.patch 2021-11-03 09:30:07.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/patches/Fix-test_has_local_network-if-local-network-is-not-p.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -From 9d7daac305741c77ef00d679e16cf4a4e4e8e588 Mon Sep 17 00:00:00 2001 -From: Benjamin Drung -Date: Wed, 3 Nov 2021 10:29:13 +0100 -Subject: Fix test_has_local_network if local network is not present - -During Debian package build on the official Debian builders, the -`skip_if_no_local_network` will fail. This will cause -`test_has_local_network` to fail. - -So mock `socket.socket` to ensure that `test_has_local_network` will -work regardless of the environment it is executed it. - -Forwarded: https://github.com/s0undt3ch/pytest-skip-markers/pull/2 -Signed-off-by: Benjamin Drung ---- - tests/functional/markers/test_requires_network.py | 9 +++++++-- - .../unit/utils/markers/test_skip_if_no_remote_network.py | 3 ++- - 2 files changed, 9 insertions(+), 3 deletions(-) - -diff --git a/tests/functional/markers/test_requires_network.py b/tests/functional/markers/test_requires_network.py -index 0b21ede..8d885c7 100644 ---- a/tests/functional/markers/test_requires_network.py -+++ b/tests/functional/markers/test_requires_network.py -@@ -20,8 +20,13 @@ def test_has_local_network(pytester): - assert True - """ - ) -- res = pytester.runpytest() -- res.assert_outcomes(passed=1) -+ with mock.patch( -+ "saltfactories.utils.ports.get_unused_localhost_port", -+ side_effect=[ports.get_unused_localhost_port() for n in range(10)], -+ ): -+ with mock.patch("saltfactories.utils.markers.socket.socket"): -+ res = pytester.runpytest() -+ res.assert_outcomes(passed=1) - res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") - - -diff --git a/tests/unit/utils/markers/test_skip_if_no_remote_network.py b/tests/unit/utils/markers/test_skip_if_no_remote_network.py -index 1aa72dc..5a820a4 100644 ---- a/tests/unit/utils/markers/test_skip_if_no_remote_network.py -+++ b/tests/unit/utils/markers/test_skip_if_no_remote_network.py -@@ -11,7 +11,8 @@ from saltfactories.utils import socket - - - def test_has_remote_network(): -- assert markers.skip_if_no_remote_network() is None -+ with mock.patch("saltfactories.utils.markers.socket.socket"): -+ assert markers.skip_if_no_remote_network() is None - - - def test_no_remote_network(): --- -2.30.2 - diff -Nru pytest-salt-factories-0.907.0/debian/patches/Fix-test_is_aarch64-with-salt-3004.patch pytest-salt-factories-0.907.0/debian/patches/Fix-test_is_aarch64-with-salt-3004.patch --- pytest-salt-factories-0.907.0/debian/patches/Fix-test_is_aarch64-with-salt-3004.patch 2021-11-03 10:57:52.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/patches/Fix-test_is_aarch64-with-salt-3004.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -From 8a44545bc279fa13867a8a3610205f061cecc882 Mon Sep 17 00:00:00 2001 -From: Benjamin Drung -Date: Wed, 3 Nov 2021 11:50:53 +0100 -Subject: Fix test_is_aarch64 with salt 3004 - -The tests `test_is_aarch64` and `test_is_not_aarch64` do not mock -`is_aarch64` if salt >= 3004 is installed. Import logic and tests from -`pytest-skip-markers`. - -Signed-off-by: Benjamin Drung ---- - src/saltfactories/utils/platform.py | 7 ++----- - tests/unit/utils/test_platforms.py | 4 ++-- - 2 files changed, 4 insertions(+), 7 deletions(-) - -diff --git a/src/saltfactories/utils/platform.py b/src/saltfactories/utils/platform.py -index 5039c2e..6530aad 100644 ---- a/src/saltfactories/utils/platform.py -+++ b/src/saltfactories/utils/platform.py -@@ -8,6 +8,7 @@ saltfactories.utils.platform - - Platform related utilities - """ -+import platform - import sys - - import salt.utils.platform -@@ -90,11 +91,7 @@ def is_aarch64(): - """ - Simple function to return if host is AArch64 or not - """ -- try: -- return salt.utils.platform.is_aarch64() -- except AttributeError: -- # Salt < 3004 -- return sys.platform.startswith("aarch64") -+ return platform.machine().startswith("aarch64") - - - def on_platforms( -diff --git a/tests/unit/utils/test_platforms.py b/tests/unit/utils/test_platforms.py -index 8933e54..4c62c9d 100644 ---- a/tests/unit/utils/test_platforms.py -+++ b/tests/unit/utils/test_platforms.py -@@ -119,11 +119,11 @@ def test_is_not_aix(): - - def test_is_aarch64(): - return_value = True -- with mock.patch("sys.platform", "aarch64"): -+ with mock.patch("platform.machine", return_value="aarch64"): - assert saltfactories.utils.platform.is_aarch64() is return_value - - - def test_is_not_aarch64(): - return_value = False -- with mock.patch("sys.platform", "not_aarch64"): -+ with mock.patch("platform.machine", return_value="not_aarch64"): - assert saltfactories.utils.platform.is_aarch64() is return_value --- -2.30.2 - diff -Nru pytest-salt-factories-0.907.0/debian/patches/Fix-tests-that-assume-python-binaries-being-present.patch pytest-salt-factories-0.907.0/debian/patches/Fix-tests-that-assume-python-binaries-being-present.patch --- pytest-salt-factories-0.907.0/debian/patches/Fix-tests-that-assume-python-binaries-being-present.patch 2021-10-26 17:02:23.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/patches/Fix-tests-that-assume-python-binaries-being-present.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -From 9fad67cfcca3cc5b5a9626009ed21a9a9286d329 Mon Sep 17 00:00:00 2001 -From: Benjamin Drung -Date: Tue, 26 Oct 2021 18:26:07 +0200 -Subject: Fix tests that assume python binaries being present - -On Debian based system, the Python binary includes the version and is -named `python3`. The test cases that expect that a binary named `python` -exists will fail. - -Use the binary name of the running Python process for the test cases to -ensure that this binary is present. - -Forwarded: https://github.com/s0undt3ch/pytest-skip-markers/pull/1 -Signed-off-by: Benjamin Drung ---- - .../markers/test_skip_if_binaries_missing.py | 26 ++++++++++++++----- - 1 file changed, 20 insertions(+), 6 deletions(-) - -diff --git a/tests/functional/markers/test_skip_if_binaries_missing.py b/tests/functional/markers/test_skip_if_binaries_missing.py -index 258289e..45933ca 100644 ---- a/tests/functional/markers/test_skip_if_binaries_missing.py -+++ b/tests/functional/markers/test_skip_if_binaries_missing.py -@@ -5,6 +5,16 @@ - Test the ``@pytest.mark.skip_if_binaries_missing`` marker - """ - -+import os -+import sys -+ -+import pytest -+ -+ -+@pytest.fixture -+def python_binary(): -+ return os.path.basename(sys.executable) -+ - - def test_skipped(pytester): - pytester.makepyfile( -@@ -36,30 +46,34 @@ def test_skipped_multiple_binaries(pytester): - res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") - - --def test_not_skipped(pytester): -+def test_not_skipped(pytester, python_binary): - pytester.makepyfile( - """ - import pytest - -- @pytest.mark.skip_if_binaries_missing("python") -+ @pytest.mark.skip_if_binaries_missing("{}") - def test_one(): - assert True -- """ -+ """.format( -+ python_binary -+ ) - ) - res = pytester.runpytest_inprocess("-ra", "-vv") - res.assert_outcomes(passed=1) - res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") - - --def test_not_skipped_multiple_binaries(pytester): -+def test_not_skipped_multiple_binaries(pytester, python_binary): - pytester.makepyfile( - """ - import pytest - -- @pytest.mark.skip_if_binaries_missing("python", "pip") -+ @pytest.mark.skip_if_binaries_missing("{}", "pip") - def test_one(): - assert True -- """ -+ """.format( -+ python_binary -+ ) - ) - res = pytester.runpytest_inprocess("-ra", "-vv") - res.assert_outcomes(passed=1) --- -2.30.2 - diff -Nru pytest-salt-factories-0.907.0/debian/patches/series pytest-salt-factories-0.907.0/debian/patches/series --- pytest-salt-factories-0.907.0/debian/patches/series 2021-11-03 10:57:52.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/patches/series 2022-04-15 22:05:06.000000000 +0000 @@ -1,4 +1,2 @@ Drop-setuptools-declarative-requirements.patch -Fix-tests-that-assume-python-binaries-being-present.patch -Fix-test_has_local_network-if-local-network-is-not-p.patch -Fix-test_is_aarch64-with-salt-3004.patch +Switch-to-pytest-skip-markers.patch diff -Nru pytest-salt-factories-0.907.0/debian/patches/Switch-to-pytest-skip-markers.patch pytest-salt-factories-0.907.0/debian/patches/Switch-to-pytest-skip-markers.patch --- pytest-salt-factories-0.907.0/debian/patches/Switch-to-pytest-skip-markers.patch 1970-01-01 00:00:00.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/patches/Switch-to-pytest-skip-markers.patch 2022-04-15 22:05:06.000000000 +0000 @@ -0,0 +1,4097 @@ +From: Pedro Algarvio +Date: Mon, 4 Oct 2021 18:13:25 +0100 +Subject: Switch to pytest-skip-markers + +Origin: upstream, commit: 064ab1f0e5419a1a6c54a70cfe58b7a1c1f9c138 +--- + changelog/84.improvement.rst | 1 + + docs/ref/saltfactories/plugins/markers.rst | 549 +------------------- + docs/ref/saltfactories/utils/platform.rst | 5 - + requirements/base.txt | 1 + + src/saltfactories/bases.py | 4 +- + src/saltfactories/daemons/minion.py | 6 +- + src/saltfactories/daemons/proxy.py | 6 +- + src/saltfactories/daemons/sshd.py | 3 +- + src/saltfactories/plugins/__init__.py | 6 +- + src/saltfactories/plugins/log_server.py | 4 +- + src/saltfactories/plugins/markers.py | 152 ------ + src/saltfactories/plugins/sysstats.py | 4 +- + src/saltfactories/utils/markers.py | 574 +-------------------- + src/saltfactories/utils/platform.py | 156 ------ + src/saltfactories/utils/virtualenv.py | 2 +- + .../factories/base/test_daemon_factory.py | 2 +- + tests/functional/markers/test_destructive_test.py | 60 --- + tests/functional/markers/test_expensive_test.py | 60 --- + tests/functional/markers/test_requires_network.py | 47 -- + .../markers/test_skip_if_binaries_missing.py | 66 --- + tests/functional/markers/test_skip_if_not_root.py | 74 --- + tests/functional/markers/test_skip_on_aarch64.py | 55 -- + tests/functional/markers/test_skip_on_aix.py | 58 --- + tests/functional/markers/test_skip_on_darwin.py | 58 --- + tests/functional/markers/test_skip_on_freebsd.py | 58 --- + tests/functional/markers/test_skip_on_linux.py | 58 --- + tests/functional/markers/test_skip_on_netbsd.py | 58 --- + tests/functional/markers/test_skip_on_openbsd.py | 58 --- + tests/functional/markers/test_skip_on_platforms.py | 128 ----- + tests/functional/markers/test_skip_on_smartos.py | 58 --- + tests/functional/markers/test_skip_on_sunos.py | 58 --- + tests/functional/markers/test_skip_on_windows.py | 58 --- + .../markers/test_skip_unless_on_aarch64.py | 55 -- + .../functional/markers/test_skip_unless_on_aix.py | 58 --- + .../markers/test_skip_unless_on_darwin.py | 58 --- + .../markers/test_skip_unless_on_freebsd.py | 58 --- + .../markers/test_skip_unless_on_linux.py | 58 --- + .../markers/test_skip_unless_on_netbsd.py | 58 --- + .../markers/test_skip_unless_on_openbsd.py | 58 --- + .../markers/test_skip_unless_on_platforms.py | 130 ----- + .../markers/test_skip_unless_on_smartos.py | 58 --- + .../markers/test_skip_unless_on_sunos.py | 58 --- + .../markers/test_skip_unless_on_windows.py | 58 --- + .../functional/utils/saltext/test_log_handlers.py | 6 +- + .../factories/daemons/proxy/test_proxy_minion.py | 11 +- + .../factories/daemons/proxy/test_restarts.py | 11 +- + .../utils/markers/test_skip_if_binaries_missing.py | 72 --- + .../utils/markers/test_skip_if_no_local_network.py | 28 - + .../markers/test_skip_if_no_remote_network.py | 23 - + tests/unit/utils/markers/test_skip_if_not_root.py | 28 - + tests/unit/utils/test_platforms.py | 129 ----- + 51 files changed, 39 insertions(+), 3463 deletions(-) + create mode 100644 changelog/84.improvement.rst + delete mode 100644 docs/ref/saltfactories/utils/platform.rst + delete mode 100644 src/saltfactories/utils/platform.py + delete mode 100644 tests/functional/markers/test_destructive_test.py + delete mode 100644 tests/functional/markers/test_expensive_test.py + delete mode 100644 tests/functional/markers/test_requires_network.py + delete mode 100644 tests/functional/markers/test_skip_if_binaries_missing.py + delete mode 100644 tests/functional/markers/test_skip_if_not_root.py + delete mode 100644 tests/functional/markers/test_skip_on_aarch64.py + delete mode 100644 tests/functional/markers/test_skip_on_aix.py + delete mode 100644 tests/functional/markers/test_skip_on_darwin.py + delete mode 100644 tests/functional/markers/test_skip_on_freebsd.py + delete mode 100644 tests/functional/markers/test_skip_on_linux.py + delete mode 100644 tests/functional/markers/test_skip_on_netbsd.py + delete mode 100644 tests/functional/markers/test_skip_on_openbsd.py + delete mode 100644 tests/functional/markers/test_skip_on_platforms.py + delete mode 100644 tests/functional/markers/test_skip_on_smartos.py + delete mode 100644 tests/functional/markers/test_skip_on_sunos.py + delete mode 100644 tests/functional/markers/test_skip_on_windows.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_aarch64.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_aix.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_darwin.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_freebsd.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_linux.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_netbsd.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_openbsd.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_platforms.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_smartos.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_sunos.py + delete mode 100644 tests/functional/markers/test_skip_unless_on_windows.py + delete mode 100644 tests/unit/utils/markers/test_skip_if_binaries_missing.py + delete mode 100644 tests/unit/utils/markers/test_skip_if_no_local_network.py + delete mode 100644 tests/unit/utils/markers/test_skip_if_no_remote_network.py + delete mode 100644 tests/unit/utils/markers/test_skip_if_not_root.py + delete mode 100644 tests/unit/utils/test_platforms.py + +diff --git a/changelog/84.improvement.rst b/changelog/84.improvement.rst +new file mode 100644 +index 0000000..3b3abe4 +--- /dev/null ++++ b/changelog/84.improvement.rst +@@ -0,0 +1 @@ ++Switch to `pytest-skip-markers `_. +diff --git a/docs/ref/saltfactories/plugins/markers.rst b/docs/ref/saltfactories/plugins/markers.rst +index 6a185d0..a403a12 100644 +--- a/docs/ref/saltfactories/plugins/markers.rst ++++ b/docs/ref/saltfactories/plugins/markers.rst +@@ -2,553 +2,10 @@ + Markers + ======= + +-Salt factories ships with quite a few markers, skip markers. +- +- +-.. _markers.destructive_test: +- +-``destructive_test`` +-==================== +- +-.. py:decorator:: pytest.mark.destructive_test +- +- Skip the test if ``--run-destructive`` is not passed to pytest on the CLI. +- +- Use this mark when the test does something destructive to the system where the tests are running, for example, +- adding or removing a user, changing a user password. +- +- .. admonition:: Note +- +- Do not use this marker if all the test does is add/remove/change files in the test suite temporary directory +- +- .. code-block:: python +- +- @pytest.mark.destructive_test +- def test_func(): +- assert True +- +- +- +-.. _markers.expensive_test: +- +-``expensive_test`` +-================== +- +-.. py:decorator:: pytest.mark.expensive_test +- +- Skip the test if ``--run-expensive`` is not passed to pytest on the CLI. +- +- Use this test when the test does something expensive(as in monetary expensive), like creating a virtual +- machine on a cloud provider, etc. +- +- .. code-block:: python +- +- @pytest.mark.expensive_test +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_if_not_root: +- +-``skip_if_not_root`` +-==================== +- +-.. py:decorator:: pytest.mark.skip_if_not_root +- +- Skip the test if the user running the test suite is not ``root`` or ``Administrator`` on Windows. +- +- .. code-block:: python +- +- @pytest.mark.skip_if_not_root +- def test_func(): +- assert True +- +- Look :py:func:`here ` for the full function signature. +- +- +- +-.. _markers.skip_if_binaries_missing: +- +-``skip_if_binaries_missing`` +-============================ +- +-.. py:decorator:: pytest.mark.skip_if_binaries_missing(\*binaries, check_all=True, reason=None) +- +- :param str binaries: +- Any argument passed must be a :py:class:`str` which is the name of the binary +- check for presence in the path. Multiple arguments can be passed. +- :keyword bool check_all: +- If ``check_all`` is :py:const:`True`, the default, all binaries must exist. +- If ``check_all`` is :py:class:`False`, then only one the passed binaries needs to be found. +- Useful when, for example, passing a list of python interpreter names(python3.5, +- python3, python), where only one needs to exist. +- :keyword str reason: +- The skip reason. +- +- Skip tests if binaries are not found in path. +- +- .. code-block:: python +- +- @pytest.mark.skip_if_binaries_missing("sshd") +- def test_func(): +- assert True +- +- +- @pytest.mark.skip_if_binaries_missing("python3.7", "python3", "python", check_all=False) +- def test_func(): +- assert True +- +- Look :py:func:`here ` for the full function signature. +- +- +- +-.. _markers.requires_network: +- +-``requires_network`` +-==================== +- +- +- +-.. _markers.skip_on_windows: +- +-``skip_on_windows`` +-=================== +- +-.. py:decorator:: pytest.mark.skip_on_windows(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on windows. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_windows +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_windows: +- +-``skip_unless_on_windows`` +-========================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_windows(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on windows. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_windows +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_linux: +- +-``skip_on_linux`` +-================= +- +-.. py:decorator:: pytest.mark.skip_on_linux(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on linux. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_linux +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_linux: +- +-``skip_unless_on_linux`` +-======================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_linux(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on linux. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_linux +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_darwin: +- +-``skip_on_darwin`` +-================== +- +-.. py:decorator:: pytest.mark.skip_on_darwin(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on darwin. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_darwin +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_darwin: +- +-``skip_unless_on_darwin`` +-========================= +- +-.. py:decorator:: pytest.mark.skip_unless_on_darwin(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on darwin. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_darwin +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_sunos: +- +-``skip_on_sunos`` +-================= +- +-.. py:decorator:: pytest.mark.skip_on_sunos(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on sunos. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_sunos +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_sunos: +- +-``skip_unless_on_sunos`` +-======================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_sunos(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on sunos. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_sunos +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_smartos: +- +-``skip_on_smartos`` +-=================== +- +-.. py:decorator:: pytest.mark.skip_on_smartos(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on smartos. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_smartos +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_smartos: +- +-``skip_unless_on_smartos`` +-========================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_smartos(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on smartos. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_smartos +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_freebsd: +- +-``skip_on_freebsd`` +-=================== +- +-.. py:decorator:: pytest.mark.skip_on_freebsd(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on freebsd. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_freebsd +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_freebsd: +- +-``skip_unless_on_freebsd`` +-========================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_freebsd(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on freebsd. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_freebsd +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_netbsd: +- +-``skip_on_netbsd`` +-================== +- +-.. py:decorator:: pytest.mark.skip_on_netbsd(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on netbsd. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_netbsd +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_netbsd: +- +-``skip_unless_on_netbsd`` +-========================= +- +-.. py:decorator:: pytest.mark.skip_unless_on_netbsd(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on netbsd. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_netbsd +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_openbsd: +- +-``skip_on_openbsd`` +-=================== +- +-.. py:decorator:: pytest.mark.skip_on_openbsd(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on openbsd. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_openbsd +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_openbsd: +- +-``skip_unless_on_openbsd`` +-========================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_openbsd(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on openbsd. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_openbsd +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_aix: +- +-``skip_on_aix`` +-=============== +- +-.. py:decorator:: pytest.mark.skip_on_aix(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on aix. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_aix +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_aix: +- +-``skip_unless_on_aix`` +-====================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_aix(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on aix. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_aix +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_aarch64: +- +-``skip_on_aarch64`` +-=================== +- +-.. py:decorator:: pytest.mark.skip_on_aarch64(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test if test suite is running on aarch64. +- +- .. code-block:: python +- +- @pytest.mark.skip_on_aarch64 +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_aarch64: +- +-``skip_unless_on_aarch64`` +-========================== +- +-.. py:decorator:: pytest.mark.skip_unless_on_aarch64(reason=None) +- +- :keyword str reason: The skip reason +- +- Skip test unless the test suite is running on aarch64. +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_aarch64 +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_on_platforms: +- +-``skip_on_platforms`` +-===================== +- +-.. py:decorator:: pytest.mark.skip_on_platforms(**platforms, reason=None) +- +- :keyword bool windows: Skip on windows if :py:const:`True` +- :keyword bool linux: Skip on linux if :py:const:`True` +- :keyword bool darwin: Skip on darwin if :py:const:`True` +- :keyword bool sunos: Skip on sunos if :py:const:`True` +- :keyword bool smartos: Skip on smartos if :py:const:`True` +- :keyword bool freebsd: Skip on freebsd if :py:const:`True` +- :keyword bool netbsd: Skip on netbsd if :py:const:`True` +- :keyword bool openbsd: Skip on openbsd if :py:const:`True` +- :keyword bool aix: Skip on aix if :py:const:`True` +- :keyword bool aarch64: Skip on aarch64 if :py:const:`True` +- :keyword str reason: The skip reason +- +- Pass :py:const:`True` to any of the platforms defined as keyword arguments to skip the test when running on that +- platform +- +- .. code-block:: python +- +- @pytest.mark.skip_on_platforms(windows=True, darwin=True) +- def test_func(): +- assert True +- +- +- +-.. _markers.skip_unless_on_platforms: +- +-``skip_unless_on_platforms`` +-============================ +- +-.. py:decorator:: pytest.mark.skip_unless_on_platforms(**platforms, reason=None) +- +- :keyword bool windows: Skip unless on windows if :py:const:`True` +- :keyword bool linux: Skip unless on linux if :py:const:`True` +- :keyword bool darwin: Skip unless on darwin if :py:const:`True` +- :keyword bool sunos: Skip unless on sunos if :py:const:`True` +- :keyword bool smartos: Skip unless on smartos if :py:const:`True` +- :keyword bool freebsd: Skip unless on freebsd if :py:const:`True` +- :keyword bool netbsd: Skip unless on netbsd if :py:const:`True` +- :keyword bool openbsd: Skip unless on openbsd if :py:const:`True` +- :keyword bool aix: Skip unless on aix if :py:const:`True` +- :keyword bool aarch64: Skip on aarch64 if :py:const:`True` +- :keyword str reason: The skip reason +- +- Pass :py:const:`True` to any of the platforms defined as keyword arguments to skip the test when not running on +- that platform +- +- .. code-block:: python +- +- @pytest.mark.skip_unless_on_platforms(windows=True, darwin=True) +- def test_func(): +- assert True +- ++Salt factories ships with a few markers, skip markers. ++Additional markers used in Salt's test suite are provided by the `skip-markers`_ pytest plugin. + ++.. _skip-markers: https://pypi.org/project/pytest-skip-markers + + .. _markers.requires_salt_modules: + +diff --git a/docs/ref/saltfactories/utils/platform.rst b/docs/ref/saltfactories/utils/platform.rst +deleted file mode 100644 +index 0f7c012..0000000 +--- a/docs/ref/saltfactories/utils/platform.rst ++++ /dev/null +@@ -1,5 +0,0 @@ +-.. automodule:: saltfactories.utils.platform +- :members: +- :show-inheritance: +- :inherited-members: +- :no-undoc-members: +diff --git a/requirements/base.txt b/requirements/base.txt +index ff53afc..95385f9 100644 +--- a/requirements/base.txt ++++ b/requirements/base.txt +@@ -2,6 +2,7 @@ pytest>=6.0.0 + attrs>=19.2.0 + pytest-tempdir>=2019.9.16 + pytest-helpers-namespace>=2021.4.29 ++pytest-skip-markers + psutil + pyzmq + msgpack +diff --git a/src/saltfactories/bases.py b/src/saltfactories/bases.py +index 9380f22..7e2e2cf 100644 +--- a/src/saltfactories/bases.py ++++ b/src/saltfactories/bases.py +@@ -22,14 +22,14 @@ import salt.utils.files + import salt.utils.path + import salt.utils.verify + import salt.utils.yaml ++from pytestskipmarkers.utils import platform ++from pytestskipmarkers.utils import ports + from salt.utils.immutabletypes import freeze + + from saltfactories.exceptions import FactoryNotRunning + from saltfactories.exceptions import FactoryNotStarted + from saltfactories.exceptions import FactoryTimeout + from saltfactories.utils import format_callback_to_string +-from saltfactories.utils import platform +-from saltfactories.utils import ports + from saltfactories.utils import running_username + from saltfactories.utils import time + from saltfactories.utils.processes import ProcessResult +diff --git a/src/saltfactories/daemons/minion.py b/src/saltfactories/daemons/minion.py +index 7753d55..5e0bb28 100644 +--- a/src/saltfactories/daemons/minion.py ++++ b/src/saltfactories/daemons/minion.py +@@ -9,16 +9,16 @@ import copy + import logging + import pathlib + import shutil +-import sys + + import attr + import salt.config + import salt.utils.dictupdate ++from pytestskipmarkers.utils import platform ++from pytestskipmarkers.utils import ports + + from saltfactories import cli + from saltfactories.bases import SaltDaemon + from saltfactories.utils import cli_scripts +-from saltfactories.utils import ports + from saltfactories.utils.tempfiles import SaltPillarTree + from saltfactories.utils.tempfiles import SaltStateTree + +@@ -212,7 +212,7 @@ class SaltMinion(SaltDaemon): + + def get_script_args(self): + args = super().get_script_args() +- if sys.platform.startswith("win") is False: ++ if platform.is_windows() is False: + args.append("--disable-keepalive") + return args + +diff --git a/src/saltfactories/daemons/proxy.py b/src/saltfactories/daemons/proxy.py +index 1e82786..19d63e5 100644 +--- a/src/saltfactories/daemons/proxy.py ++++ b/src/saltfactories/daemons/proxy.py +@@ -9,17 +9,17 @@ import copy + import logging + import pathlib + import shutil +-import sys + + import attr + import salt.config + import salt.utils.dictupdate ++from pytestskipmarkers.utils import platform ++from pytestskipmarkers.utils import ports + + from saltfactories import cli + from saltfactories.bases import SaltDaemon + from saltfactories.bases import SystemdSaltDaemonImpl + from saltfactories.utils import cli_scripts +-from saltfactories.utils import ports + from saltfactories.utils.tempfiles import SaltPillarTree + from saltfactories.utils.tempfiles import SaltStateTree + +@@ -221,7 +221,7 @@ class SaltProxyMinion(SaltDaemon): + + def get_base_script_args(self): + script_args = super().get_base_script_args() +- if sys.platform.startswith("win") is False: ++ if platform.is_windows() is False: + script_args.append("--disable-keepalive") + return script_args + +diff --git a/src/saltfactories/daemons/sshd.py b/src/saltfactories/daemons/sshd.py +index ff437c0..f35e000 100644 +--- a/src/saltfactories/daemons/sshd.py ++++ b/src/saltfactories/daemons/sshd.py +@@ -8,10 +8,11 @@ import subprocess + from datetime import datetime + + import attr ++from pytestskipmarkers.utils import platform ++from pytestskipmarkers.utils import ports + + from saltfactories.bases import Daemon + from saltfactories.exceptions import FactoryFailure +-from saltfactories.utils import ports + from saltfactories.utils import running_username + from saltfactories.utils import socket + +diff --git a/src/saltfactories/plugins/__init__.py b/src/saltfactories/plugins/__init__.py +index 679acad..e78cf37 100644 +--- a/src/saltfactories/plugins/__init__.py ++++ b/src/saltfactories/plugins/__init__.py +@@ -9,8 +9,8 @@ import os + import tempfile + + import pytest ++import pytestskipmarkers.utils.platform + +-import saltfactories.utils.platform + import saltfactories.utils.tempfiles + + log = logging.getLogger(__name__) +@@ -21,9 +21,9 @@ def pytest_tempdir_temproot(): + # Avoid ${TMPDIR} and gettempdir() on MacOS as they yield a base path too long + # for unix sockets: ``error: AF_UNIX path too long`` + # Gentoo Portage prefers ebuild tests are rooted in ${TMPDIR} +- if saltfactories.utils.platform.is_windows(): ++ if pytestskipmarkers.utils.platform.is_windows(): + tempdir = "C:/Windows/Temp" +- elif saltfactories.utils.platform.is_darwin(): ++ elif pytestskipmarkers.utils.platform.is_darwin(): + tempdir = "/tmp" + else: + tempdir = os.environ.get("TMPDIR") or tempfile.gettempdir() +diff --git a/src/saltfactories/plugins/log_server.py b/src/saltfactories/plugins/log_server.py +index a09b1d3..bbce3d2 100644 +--- a/src/saltfactories/plugins/log_server.py ++++ b/src/saltfactories/plugins/log_server.py +@@ -9,9 +9,9 @@ import attr + import msgpack + import pytest + import zmq ++from pytestskipmarkers.utils import platform ++from pytestskipmarkers.utils import ports + +-from saltfactories.utils import platform +-from saltfactories.utils import ports + from saltfactories.utils import time + + log = logging.getLogger(__name__) +diff --git a/src/saltfactories/plugins/markers.py b/src/saltfactories/plugins/markers.py +index 4b6e3f5..72ad67f 100644 +--- a/src/saltfactories/plugins/markers.py ++++ b/src/saltfactories/plugins/markers.py +@@ -1,34 +1,9 @@ +-import os +- + import pytest + + import saltfactories.utils.functional + import saltfactories.utils.markers + + +-def pytest_addoption(parser): +- """ +- register argparse-style options and ini-style config values. +- """ +- test_selection_group = parser.getgroup("Tests Selection") +- test_selection_group.addoption( +- "--run-destructive", +- action="store_true", +- default=False, +- help="Run destructive tests. These tests can include adding " +- "or removing users from your system for example. " +- "Default: False", +- ) +- test_selection_group.addoption( +- "--run-expensive", +- action="store_true", +- default=False, +- help="Run expensive tests. These tests usually involve costs " +- "like for example bootstrapping a cloud VM. " +- "Default: False", +- ) +- +- + @pytest.hookimpl(tryfirst=True) + def pytest_runtest_setup(item): + """ +@@ -45,128 +20,6 @@ def pytest_configure(config): + and all plugins and initial conftest files been loaded. + """ + # Expose the markers we use to pytest CLI +- config.addinivalue_line( +- "markers", +- "destructive_test: Run destructive tests. These tests can include adding " +- "or removing users from your system for example.", +- ) +- config.addinivalue_line( +- "markers", +- "expensive_test: Run expensive tests. These tests can include starting resources " +- "which cost money, like VMs, for example.", +- ) +- config.addinivalue_line( +- "markers", +- "skip_if_not_root: Skip if the current user is not root on non windows platforms or not " +- "Administrator on windows platforms", +- ) +- config.addinivalue_line("markers", "skip_if_not_root: Skip if the current user is not `root`.") +- config.addinivalue_line( +- "markers", +- "skip_if_binaries_missing(*binaries, check_all=True, message=None):" +- "If 'check_all' is True, all binaries must exist." +- "If 'check_all' is False, then only one the passed binaries needs to be found. Usefull when, " +- "for example, passing a list of python interpreter names(python3.5, python3, python), where " +- "only one needs to exist.", +- ) +- config.addinivalue_line( +- "markers", +- "requires_network(only_local_network=False): Skip if no networking is set up. " +- "If 'only_local_network' is 'True', only the local network is checked.", +- ) +- # Platform Skip Markers +- config.addinivalue_line( +- "markers", +- "skip_on_windows: Skip test on Windows", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_windows: Skip test unless on Windows", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_linux: Skip test on Linux", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_linux: Skip test unless on Linux", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_darwin: Skip test on Darwin", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_darwin: Skip test unless on Darwin", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_sunos: Skip test on SunOS", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_sunos: Skip test unless on SunOS", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_smartos: Skip test on SmartOS", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_smartos: Skip test unless on SmartOS", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_freebsd: Skip test on FreeBSD", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_freebsd: Skip test unless on FreeBSD", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_netbsd: Skip test on NetBSD", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_netbsd: Skip test unless on NetBSD", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_openbsd: Skip test on OpenBSD", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_openbsd: Skip test unless on OpenBSD", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_aix: Skip test on AIX", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_aix: Skip test unless on AIX", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_aarch64: Skip test on AArch64", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_aarch64: Skip test unless on AArch64", +- ) +- config.addinivalue_line( +- "markers", +- "skip_on_platforms(windows=False, linux=False, darwin=False, sunos=False, smartos=False, freebsd=False, " +- "netbsd=False, openbsd=False, aix=False, aarch64=False): Pass True to one or more platform names to get the test skipped " +- "on those platforms", +- ) +- config.addinivalue_line( +- "markers", +- "skip_unless_on_platforms(windows=False, linux=False, darwin=False, sunos=False, smartos=False, freebsd=False, " +- "netbsd=False, openbsd=False, aix=False, aarch64=False): Pass True to one or more platform names to get the test skipped " +- "unless the chosen platforms match", +- ) + config.addinivalue_line( + "markers", + "requires_salt_modules(*required_module_names): Skip if at least one module is not available.", +@@ -176,11 +29,6 @@ def pytest_configure(config): + "requires_salt_states(*required_state_names): Skip if at least one state module is not available.", + ) + +- # Add keys to environ in order to support Salt's helper decorators while it does not migrate to pytest markers +- env2cli = (("DESTRUCTIVE_TESTS", "--run-destructive"), ("EXPENSIVE_TESTS", "--run-expensive")) +- for envkey, cliflag in env2cli: +- os.environ[str(envkey)] = str(config.getoption(cliflag)).lower() +- + + @pytest.fixture(scope="session") + def session_markers_loader(salt_factories): +diff --git a/src/saltfactories/plugins/sysstats.py b/src/saltfactories/plugins/sysstats.py +index 5161737..47f8ba1 100644 +--- a/src/saltfactories/plugins/sysstats.py ++++ b/src/saltfactories/plugins/sysstats.py +@@ -6,12 +6,12 @@ System Statistics + Process stats PyTest plugin interface + """ + import os +-import sys + from collections import OrderedDict + + import attr + import psutil + import pytest ++from pytestskipmarkers.utils import platform + + + @attr.s(kw_only=True, slots=True, hash=True) +@@ -52,7 +52,7 @@ class SystemStatsReporter: + self.sys_stats_no_children = self.config.getoption("--sys-stats-no-children") is True + if self.config.getoption("--sys-stats-uss-mem") is True: + self.sys_stats_mem_type = "uss" +- if sys.platform.startswith("freebsd"): ++ if platform.is_freebsd(): + # FreeBSD doesn't apparently support uss + self.sys_stats_mem_type = "rss" + else: +diff --git a/src/saltfactories/utils/markers.py b/src/saltfactories/utils/markers.py +index a504c40..7343e34 100644 +--- a/src/saltfactories/utils/markers.py ++++ b/src/saltfactories/utils/markers.py +@@ -8,147 +8,14 @@ saltfactories.utils.markers + + PyTest Markers related utilities + """ +-import contextlib + import fnmatch + import logging +-import os +-import sys + + import pytest +-import salt.utils.path +-import salt.utils.win_functions +- +-import saltfactories.utils.platform +-import saltfactories.utils.ports as ports +-import saltfactories.utils.socket as socket + + log = logging.getLogger(__name__) + + +-def skip_if_not_root(): +- """ +- Helper function to check for root/Administrator privileges +- +- Returns: +- str: The reason of the skip +- """ +- if not sys.platform.startswith("win"): +- if os.getuid() != 0: +- return "You must be logged in as root to run this test" +- else: +- current_user = salt.utils.win_functions.get_current_user() +- if current_user != "SYSTEM": +- if not salt.utils.win_functions.is_admin(current_user): +- return "You must be logged in as an Administrator to run this test" +- +- +-def skip_if_binaries_missing(binaries, check_all=True, reason=None): +- """ +- Helper function to check for existing binaries +- +- Args: +- binaries (list or tuple): +- Iterator of binaries to check +- check_all (bool): +- If ``check_all`` is ``True``, the default, all binaries must exist. +- If ``check_all`` is ``False``, then only one the passed binaries needs to be found. +- Useful when, for example, passing a list of python interpreter names(python3.5, +- python3, python), where only one needs to exist. +- reason (str): +- The skip reason. +- +- Returns: +- str: The reason for the skip. +- None: Should not be skipped. +- """ +- if check_all is False: +- # We only need one of the passed binaries to exist +- if salt.utils.path.which_bin(binaries) is None: +- if reason is not None: +- return reason +- return "None of the following binaries was found: {}".format(", ".join(binaries)) +- else: +- for binary in binaries: +- if salt.utils.path.which(binary) is None: +- if reason is not None: +- return reason +- return "The '{}' binary was not found".format(binary) +- log.debug("All binaries found. Searched for: %s", ", ".join(binaries)) +- +- +-def skip_if_no_local_network(): +- """ +- Helper function to check for existing local network +- +- Returns: +- str: The reason for the skip. +- None: Should not be skipped. +- """ +- check_port = ports.get_unused_localhost_port() +- has_local_network = False +- try: +- with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as pubsock: +- pubsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +- pubsock.bind(("", check_port)) +- has_local_network = True +- except OSError: +- # I wonder if we just have IPV6 support? +- try: +- with contextlib.closing(socket.socket(socket.AF_INET6, socket.SOCK_STREAM)) as pubsock: +- pubsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +- pubsock.bind(("", check_port)) +- has_local_network = True +- except OSError: +- # Let's continue +- pass +- if has_local_network is False: +- return "No local network was detected" +- +- +-def skip_if_no_remote_network(): +- """ +- Helper function to check for existing remote network(internet) +- +- Returns: +- str: The reason for the skip. +- None: Should not be skipped. +- """ +- +- # We are using the google.com DNS records as numerical IPs to avoid +- # DNS look ups which could greatly slow down this check +- has_remote_network = False +- for addr in ( +- "172.217.17.14", +- "172.217.16.238", +- "173.194.41.198", +- "173.194.41.199", +- "173.194.41.200", +- "173.194.41.201", +- "173.194.41.206", +- "173.194.41.192", +- "173.194.41.193", +- "173.194.41.194", +- "173.194.41.195", +- "173.194.41.196", +- "173.194.41.197", +- "216.58.201.174", +- ): +- try: +- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +- sock.settimeout(0.25) +- sock.connect((addr, 80)) +- sock.close() +- # We connected? Stop the loop +- has_remote_network = True +- break +- except OSError: +- # Let's check the next IP +- continue +- +- if has_remote_network is False: +- return "No internet network connection was detected" +- +- + def check_required_loader_attributes(loader_instance, loader_attr, required_items): + """ + :type loader_instance: ~saltfactories.utils.functional.Loaders +@@ -194,447 +61,8 @@ def evaluate_markers(item): + """ + Fixtures injection based on markers or test skips based on CLI arguments + """ +- destructive_tests_marker = item.get_closest_marker("destructive_test") +- if destructive_tests_marker is not None: +- if destructive_tests_marker.args or destructive_tests_marker.kwargs: +- raise pytest.UsageError( +- "The 'destructive_test' marker does not accept any arguments or keyword arguments" +- ) +- if item.config.getoption("--run-destructive") is False: +- item._skipped_by_mark = True +- pytest.skip("Destructive tests are disabled") +- +- expensive_tests_marker = item.get_closest_marker("expensive_test") +- if expensive_tests_marker is not None: +- if expensive_tests_marker.args or expensive_tests_marker.kwargs: +- raise pytest.UsageError( +- "The 'expensive_test' marker does not accept any arguments or keyword arguments" +- ) +- if item.config.getoption("--run-expensive") is False: +- item._skipped_by_mark = True +- pytest.skip("Expensive tests are disabled") +- +- skip_if_not_root_marker = item.get_closest_marker("skip_if_not_root") +- if skip_if_not_root_marker is not None: +- if skip_if_not_root_marker.args or skip_if_not_root_marker.kwargs: +- raise pytest.UsageError( +- "The 'skip_if_not_root' marker does not accept any arguments or keyword arguments" +- ) +- skip_reason = skip_if_not_root() +- if skip_reason: +- item._skipped_by_mark = True +- pytest.skip(skip_reason) +- +- skip_if_binaries_missing_marker = item.get_closest_marker("skip_if_binaries_missing") +- if skip_if_binaries_missing_marker is not None: +- binaries = skip_if_binaries_missing_marker.args +- if not binaries: +- raise pytest.UsageError( +- "The 'skip_if_binaries_missing' marker needs at least one binary name to be passed" +- ) +- for arg in binaries: +- if not isinstance(arg, str): +- raise pytest.UsageError( +- "The 'skip_if_binaries_missing' marker only accepts strings as arguments. If you are " +- "trying to pass multiple binaries, each binary should be an separate argument." +- ) +- message = skip_if_binaries_missing_marker.kwargs.pop("message", None) +- if message: +- item.warn( +- """Please stop passing 'message="{0}"' and instead pass 'reason="{0}"'""".format( +- message +- ) +- ) +- skip_if_binaries_missing_marker.kwargs["reason"] = message +- skip_reason = skip_if_binaries_missing(binaries, **skip_if_binaries_missing_marker.kwargs) +- if skip_reason: +- item._skipped_by_mark = True +- pytest.skip(skip_reason) +- +- requires_network_marker = item.get_closest_marker("requires_network") +- if requires_network_marker is not None: +- only_local_network = requires_network_marker.kwargs.get("only_local_network", False) +- local_skip_reason = skip_if_no_local_network() +- if local_skip_reason: +- # Since we're only supposed to check local network, and no +- # local network was detected, skip the test +- item._skipped_by_mark = True +- pytest.skip(local_skip_reason) +- +- if only_local_network is False: +- remote_skip_reason = skip_if_no_remote_network() +- if remote_skip_reason: +- item._skipped_by_mark = True +- pytest.skip(remote_skip_reason) +- +- # Platform Skip Markers +- skip_on_windows_marker = item.get_closest_marker("skip_on_windows") +- if skip_on_windows_marker is not None: +- if skip_on_windows_marker.args: +- raise pytest.UsageError("The skip_on_windows marker does not accept any arguments") +- reason = skip_on_windows_marker.kwargs.pop("reason", None) +- if skip_on_windows_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_windows marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on Windows" +- if saltfactories.utils.platform.is_windows(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_windows_marker = item.get_closest_marker("skip_unless_on_windows") +- if skip_unless_on_windows_marker is not None: +- if skip_unless_on_windows_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_windows marker does not accept any arguments" +- ) +- reason = skip_unless_on_windows_marker.kwargs.pop("reason", None) +- if skip_unless_on_windows_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_windows marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not Windows, skipped" +- if not saltfactories.utils.platform.is_windows(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_linux_marker = item.get_closest_marker("skip_on_linux") +- if skip_on_linux_marker is not None: +- if skip_on_linux_marker.args: +- raise pytest.UsageError("The skip_on_linux marker does not accept any arguments") +- reason = skip_on_linux_marker.kwargs.pop("reason", None) +- if skip_on_linux_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_linux marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on Linux" +- if saltfactories.utils.platform.is_linux(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_linux_marker = item.get_closest_marker("skip_unless_on_linux") +- if skip_unless_on_linux_marker is not None: +- if skip_unless_on_linux_marker.args: +- raise pytest.UsageError("The skip_unless_on_linux marker does not accept any arguments") +- reason = skip_unless_on_linux_marker.kwargs.pop("reason", None) +- if skip_unless_on_linux_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_linux marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not Linux, skipped" +- if not saltfactories.utils.platform.is_linux(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_darwin_marker = item.get_closest_marker("skip_on_darwin") +- if skip_on_darwin_marker is not None: +- if skip_on_darwin_marker.args: +- raise pytest.UsageError("The skip_on_darwin marker does not accept any arguments") +- reason = skip_on_darwin_marker.kwargs.pop("reason", None) +- if skip_on_darwin_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_darwin marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on Darwin" +- if saltfactories.utils.platform.is_darwin(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_darwin_marker = item.get_closest_marker("skip_unless_on_darwin") +- if skip_unless_on_darwin_marker is not None: +- if skip_unless_on_darwin_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_darwin marker does not accept any arguments" +- ) +- reason = skip_unless_on_darwin_marker.kwargs.pop("reason", None) +- if skip_unless_on_darwin_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_darwin marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not Darwin, skipped" +- if not saltfactories.utils.platform.is_darwin(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_sunos_marker = item.get_closest_marker("skip_on_sunos") +- if skip_on_sunos_marker is not None: +- if skip_on_sunos_marker.args: +- raise pytest.UsageError("The skip_on_sunos marker does not accept any arguments") +- reason = skip_on_sunos_marker.kwargs.pop("reason", None) +- if skip_on_sunos_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_sunos marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on SunOS" +- if saltfactories.utils.platform.is_sunos(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_sunos_marker = item.get_closest_marker("skip_unless_on_sunos") +- if skip_unless_on_sunos_marker is not None: +- if skip_unless_on_sunos_marker.args: +- raise pytest.UsageError("The skip_unless_on_sunos marker does not accept any arguments") +- reason = skip_unless_on_sunos_marker.kwargs.pop("reason", None) +- if skip_unless_on_sunos_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_sunos marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not SunOS, skipped" +- if not saltfactories.utils.platform.is_sunos(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_smartos_marker = item.get_closest_marker("skip_on_smartos") +- if skip_on_smartos_marker is not None: +- if skip_on_smartos_marker.args: +- raise pytest.UsageError("The skip_on_smartos marker does not accept any arguments") +- reason = skip_on_smartos_marker.kwargs.pop("reason", None) +- if skip_on_smartos_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_smartos marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on SmartOS" +- if saltfactories.utils.platform.is_smartos(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_smartos_marker = item.get_closest_marker("skip_unless_on_smartos") +- if skip_unless_on_smartos_marker is not None: +- if skip_unless_on_smartos_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_smartos marker does not accept any arguments" +- ) +- reason = skip_unless_on_smartos_marker.kwargs.pop("reason", None) +- if skip_unless_on_smartos_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_smartos marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not SmartOS, skipped" +- if not saltfactories.utils.platform.is_smartos(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_freebsd_marker = item.get_closest_marker("skip_on_freebsd") +- if skip_on_freebsd_marker is not None: +- if skip_on_freebsd_marker.args: +- raise pytest.UsageError("The skip_on_freebsd marker does not accept any arguments") +- reason = skip_on_freebsd_marker.kwargs.pop("reason", None) +- if skip_on_freebsd_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_freebsd marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on FreeBSD" +- if saltfactories.utils.platform.is_freebsd(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_freebsd_marker = item.get_closest_marker("skip_unless_on_freebsd") +- if skip_unless_on_freebsd_marker is not None: +- if skip_unless_on_freebsd_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_freebsd marker does not accept any arguments" +- ) +- reason = skip_unless_on_freebsd_marker.kwargs.pop("reason", None) +- if skip_unless_on_freebsd_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_freebsd marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not FreeBSD, skipped" +- if not saltfactories.utils.platform.is_freebsd(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_netbsd_marker = item.get_closest_marker("skip_on_netbsd") +- if skip_on_netbsd_marker is not None: +- if skip_on_netbsd_marker.args: +- raise pytest.UsageError("The skip_on_netbsd marker does not accept any arguments") +- reason = skip_on_netbsd_marker.kwargs.pop("reason", None) +- if skip_on_netbsd_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_netbsd marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on NetBSD" +- if saltfactories.utils.platform.is_netbsd(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_netbsd_marker = item.get_closest_marker("skip_unless_on_netbsd") +- if skip_unless_on_netbsd_marker is not None: +- if skip_unless_on_netbsd_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_netbsd marker does not accept any arguments" +- ) +- reason = skip_unless_on_netbsd_marker.kwargs.pop("reason", None) +- if skip_unless_on_netbsd_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_netbsd marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not NetBSD, skipped" +- if not saltfactories.utils.platform.is_netbsd(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_openbsd_marker = item.get_closest_marker("skip_on_openbsd") +- if skip_on_openbsd_marker is not None: +- if skip_on_openbsd_marker.args: +- raise pytest.UsageError("The skip_on_openbsd marker does not accept any arguments") +- reason = skip_on_openbsd_marker.kwargs.pop("reason", None) +- if skip_on_openbsd_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_openbsd marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on OpenBSD" +- if saltfactories.utils.platform.is_openbsd(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_openbsd_marker = item.get_closest_marker("skip_unless_on_openbsd") +- if skip_unless_on_openbsd_marker is not None: +- if skip_unless_on_openbsd_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_openbsd marker does not accept any arguments" +- ) +- reason = skip_unless_on_openbsd_marker.kwargs.pop("reason", None) +- if skip_unless_on_openbsd_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_openbsd marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not OpenBSD, skipped" +- if not saltfactories.utils.platform.is_openbsd(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_aix_marker = item.get_closest_marker("skip_on_aix") +- if skip_on_aix_marker is not None: +- if skip_on_aix_marker.args: +- raise pytest.UsageError("The skip_on_aix marker does not accept any arguments") +- reason = skip_on_aix_marker.kwargs.pop("reason", None) +- if skip_on_aix_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_aix marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on AIX" +- if saltfactories.utils.platform.is_aix(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_aix_marker = item.get_closest_marker("skip_unless_on_aix") +- if skip_unless_on_aix_marker is not None: +- if skip_unless_on_aix_marker.args: +- raise pytest.UsageError("The skip_unless_on_aix marker does not accept any arguments") +- reason = skip_unless_on_aix_marker.kwargs.pop("reason", None) +- if skip_unless_on_aix_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_aix marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not AIX, skipped" +- if not saltfactories.utils.platform.is_aix(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_aarch64_marker = item.get_closest_marker("skip_on_aarch64") +- if skip_on_aarch64_marker is not None: +- if skip_on_aarch64_marker.args: +- raise pytest.UsageError("The skip_on_aarch64 marker does not accept any arguments") +- reason = skip_on_aarch64_marker.kwargs.pop("reason", None) +- if skip_on_aarch64_marker.kwargs: +- raise pytest.UsageError( +- "The skip_on_aarch64 marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Skipped on AArch64" +- if saltfactories.utils.platform.is_aarch64(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_unless_on_aarch64_marker = item.get_closest_marker("skip_unless_on_aarch64") +- if skip_unless_on_aarch64_marker is not None: +- if skip_unless_on_aarch64_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_aarch64 marker does not accept any arguments" +- ) +- reason = skip_unless_on_aarch64_marker.kwargs.pop("reason", None) +- if skip_unless_on_aarch64_marker.kwargs: +- raise pytest.UsageError( +- "The skip_unless_on_aarch64 marker only accepts 'reason' as a keyword argument." +- ) +- if reason is None: +- reason = "Platform is not AArch64, skipped" +- if not saltfactories.utils.platform.is_aarch64(): +- item._skipped_by_mark = True +- pytest.skip(reason) +- +- skip_on_platforms_marker = item.get_closest_marker("skip_on_platforms") +- if skip_on_platforms_marker is not None: +- if skip_on_platforms_marker.args: +- raise pytest.UsageError("The skip_on_platforms marker does not accept any arguments") +- reason = skip_on_platforms_marker.kwargs.pop("reason", None) +- if not skip_on_platforms_marker.kwargs: +- raise pytest.UsageError( +- "Pass at least one platform to skip_on_platforms as a keyword argument" +- ) +- if not any(skip_on_platforms_marker.kwargs.values()): +- raise pytest.UsageError( +- "Pass at least one platform with a True value to skip_on_platforms as a keyword argument" +- ) +- if reason is None: +- reason = "Skipped on platform match" +- try: +- if saltfactories.utils.platform.on_platforms(**skip_on_platforms_marker.kwargs): +- item._skipped_by_mark = True +- pytest.skip(reason) +- except TypeError as exc: +- raise pytest.UsageError( +- "Passed an invalid platform to skip_on_platforms: {}".format(exc) +- ) +- +- skip_unless_on_platforms_marker = item.get_closest_marker("skip_unless_on_platforms") +- if skip_unless_on_platforms_marker is not None: +- if skip_unless_on_platforms_marker.args: +- raise pytest.UsageError( +- "The skip_unless_on_platforms marker does not accept any arguments" +- ) +- reason = skip_unless_on_platforms_marker.kwargs.pop("reason", None) +- if not skip_unless_on_platforms_marker.kwargs: +- raise pytest.UsageError( +- "Pass at least one platform to skip_unless_on_platforms as a keyword argument" +- ) +- if not any(skip_unless_on_platforms_marker.kwargs.values()): +- raise pytest.UsageError( +- "Pass at least one platform with a True value to skip_unless_on_platforms as a keyword argument" +- ) +- if reason is None: +- reason = "Platform(s) do not match, skipped" +- try: +- if not saltfactories.utils.platform.on_platforms( +- **skip_unless_on_platforms_marker.kwargs +- ): +- item._skipped_by_mark = True +- pytest.skip(reason) +- except TypeError as exc: +- raise pytest.UsageError( +- "Passed an invalid platform to skip_unless_on_platforms: {}".format(exc) +- ) + +- # Next are two special markers, requires_salt_modules and requires_salt_states. These need access to a ++ # Two special markers, requires_salt_modules and requires_salt_states. These need access to a + # saltfactories.utils.functional.Loader instance + # They will use a session_markers_loader fixture to gain access to that + requires_salt_modules_marker = item.get_closest_marker("requires_salt_modules") +diff --git a/src/saltfactories/utils/platform.py b/src/saltfactories/utils/platform.py +deleted file mode 100644 +index 5039c2e..0000000 +--- a/src/saltfactories/utils/platform.py ++++ /dev/null +@@ -1,156 +0,0 @@ +-""" +-.. +- PYTEST_DONT_REWRITE +- +- +-saltfactories.utils.platform +-~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +-Platform related utilities +-""" +-import sys +- +-import salt.utils.platform +- +- +-def is_windows(): +- """ +- Simple function to return if a host is Windows or not +- :return bool: Return true on Windows +- """ +- return salt.utils.platform.is_windows() +- +- +-def is_linux(): +- """ +- Simple function to return if a host is Linux or not. +- Note for a proxy minion, we need to return something else +- :return bool: Return true on Linux +- """ +- return salt.utils.platform.is_linux() +- +- +-def is_darwin(): +- """ +- Simple function to return if a host is Darwin (macOS) or not +- :return bool: Return true on Darwin(macOS) +- """ +- return salt.utils.platform.is_darwin() +- +- +-def is_sunos(): +- """ +- Simple function to return if host is SunOS or not +- :return bool: Return true on SunOS +- """ +- return salt.utils.platform.is_sunos() +- +- +-def is_smartos(): +- """ +- Simple function to return if host is SmartOS (Illumos) or not +- :return bool: Return true on SmartOS (Illumos) +- """ +- return salt.utils.platform.is_smartos() +- +- +-def is_freebsd(): +- """ +- Simple function to return if host is FreeBSD or not +- :return bool: Return true on FreeBSD +- """ +- return salt.utils.platform.is_freebsd() +- +- +-def is_netbsd(): +- """ +- Simple function to return if host is NetBSD or not +- :return bool: Return true on NetBSD +- """ +- return salt.utils.platform.is_netbsd() +- +- +-def is_openbsd(): +- """ +- Simple function to return if host is OpenBSD or not +- :return bool: Return true on OpenBSD +- """ +- return salt.utils.platform.is_openbsd() +- +- +-def is_aix(): +- """ +- Simple function to return if host is AIX or not +- :return bool: Return true on AIX +- """ +- return salt.utils.platform.is_aix() +- +- +-def is_aarch64(): +- """ +- Simple function to return if host is AArch64 or not +- """ +- try: +- return salt.utils.platform.is_aarch64() +- except AttributeError: +- # Salt < 3004 +- return sys.platform.startswith("aarch64") +- +- +-def on_platforms( +- windows=False, +- linux=False, +- darwin=False, +- sunos=False, +- smartos=False, +- freebsd=False, +- netbsd=False, +- openbsd=False, +- aix=False, +- aarch64=False, +-): +- """ +- Check to see if we're on one of the provided platforms. +- +- :keyword bool windows: When :py:const:`True`, check if running on Windows. +- :keyword bool linux: When :py:const:`True`, check if running on Linux. +- :keyword bool darwin: When :py:const:`True`, check if running on Darwin. +- :keyword bool sunos: When :py:const:`True`, check if running on SunOS. +- :keyword bool smartos: When :py:const:`True`, check if running on SmartOS. +- :keyword bool freebsd: When :py:const:`True`, check if running on FreeBSD. +- :keyword bool netbsd: When :py:const:`True`, check if running on NetBSD. +- :keyword bool openbsd: When :py:const:`True`, check if running on OpenBSD. +- :keyword bool aix: When :py:const:`True`, check if running on AIX. +- :keyword bool aarch64: When :py:const:`True`, check if running on AArch64. +- """ +- if windows and is_windows(): +- return True +- +- if linux and is_linux(): +- return True +- +- if darwin and is_darwin(): +- return True +- +- if sunos and is_sunos(): +- return True +- +- if smartos and is_smartos(): +- return True +- +- if freebsd and is_freebsd(): +- return True +- +- if netbsd and is_netbsd(): +- return True +- +- if openbsd and is_openbsd(): +- return True +- +- if aix and is_aix(): +- return True +- +- if aarch64 and is_aarch64(): +- return True +- +- return False +diff --git a/src/saltfactories/utils/virtualenv.py b/src/saltfactories/utils/virtualenv.py +index aa10ad7..62c4eff 100644 +--- a/src/saltfactories/utils/virtualenv.py ++++ b/src/saltfactories/utils/virtualenv.py +@@ -9,9 +9,9 @@ import tempfile + import textwrap + + import attr ++from pytestskipmarkers.utils import platform + + from saltfactories.exceptions import ProcessFailed +-from saltfactories.utils import platform + from saltfactories.utils.processes import ProcessResult + + log = logging.getLogger(__name__) +diff --git a/tests/functional/factories/base/test_daemon_factory.py b/tests/functional/factories/base/test_daemon_factory.py +index 4c111e1..9fe2dec 100644 +--- a/tests/functional/factories/base/test_daemon_factory.py ++++ b/tests/functional/factories/base/test_daemon_factory.py +@@ -8,11 +8,11 @@ import time + import attr + import psutil + import pytest ++from pytestskipmarkers.utils import platform + + from saltfactories.bases import Daemon + from saltfactories.exceptions import FactoryNotRunning + from saltfactories.exceptions import FactoryNotStarted +-from saltfactories.utils import platform + from saltfactories.utils.processes import _get_cmdline + + PROCESS_START_TIMEOUT = 2 +diff --git a/tests/functional/markers/test_destructive_test.py b/tests/functional/markers/test_destructive_test.py +deleted file mode 100644 +index 1c284c5..0000000 +--- a/tests/functional/markers/test_destructive_test.py ++++ /dev/null +@@ -1,60 +0,0 @@ +-""" +- tests.functional.markers.test_destructive_test +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.destructive_test`` marker +-""" +- +- +-def test_run_destructive_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.destructive_test +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_run_destructive_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.destructive_test +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest("--run-destructive") +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_error_on_args_or_kwargs(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.destructive_test("arg") +- def test_one(): +- assert True +- +- @pytest.mark.destructive_test(kwarg="arg") +- def test_two(): +- assert True +- """ +- ) +- res = pytester.runpytest("--run-destructive") +- res.assert_outcomes(errors=2) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: The 'destructive_test' marker does not accept any arguments or keyword arguments*" +- ] +- ) +diff --git a/tests/functional/markers/test_expensive_test.py b/tests/functional/markers/test_expensive_test.py +deleted file mode 100644 +index ed06b0f..0000000 +--- a/tests/functional/markers/test_expensive_test.py ++++ /dev/null +@@ -1,60 +0,0 @@ +-""" +- tests.functional.markers.test_expensive_test +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.expensive_test`` marker +-""" +- +- +-def test_run_expensive_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.expensive_test +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_run_expensive_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.expensive_test +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest("--run-expensive") +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_error_on_args_or_kwargs(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.expensive_test("arg") +- def test_one(): +- assert True +- +- @pytest.mark.expensive_test(kwarg="arg") +- def test_two(): +- assert True +- """ +- ) +- res = pytester.runpytest("--run-destructive") +- res.assert_outcomes(errors=2) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: The 'expensive_test' marker does not accept any arguments or keyword arguments*" +- ] +- ) +diff --git a/tests/functional/markers/test_requires_network.py b/tests/functional/markers/test_requires_network.py +deleted file mode 100644 +index 0b21ede..0000000 +--- a/tests/functional/markers/test_requires_network.py ++++ /dev/null +@@ -1,47 +0,0 @@ +-""" +- tests.functional.markers.test_requires_network +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.requires_network`` marker +-""" +-from unittest import mock +- +-from saltfactories.utils import ports +-from saltfactories.utils import socket +- +- +-def test_has_local_network(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.requires_network +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_no_local_network(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.requires_network +- def test_one(): +- assert True +- """ +- ) +- mock_socket = mock.MagicMock() +- mock_socket.bind = mock.MagicMock(side_effect=socket.error) +- with mock.patch( +- "saltfactories.utils.ports.get_unused_localhost_port", +- side_effect=[ports.get_unused_localhost_port() for n in range(10)], +- ): +- with mock.patch("saltfactories.utils.markers.socket.socket", return_value=mock_socket): +- res = pytester.runpytest_inprocess("-p", "no:salt-factories-log-server") +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +diff --git a/tests/functional/markers/test_skip_if_binaries_missing.py b/tests/functional/markers/test_skip_if_binaries_missing.py +deleted file mode 100644 +index 258289e..0000000 +--- a/tests/functional/markers/test_skip_if_binaries_missing.py ++++ /dev/null +@@ -1,66 +0,0 @@ +-""" +- tests.functional.markers.test_skip_if_binaries_missing +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_if_binaries_missing`` marker +-""" +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_if_binaries_missing("python9") +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skipped_multiple_binaries(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_if_binaries_missing("python", "python9", check_all=True) +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_if_binaries_missing("python") +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess("-ra", "-vv") +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped_multiple_binaries(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_if_binaries_missing("python", "pip") +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess("-ra", "-vv") +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +diff --git a/tests/functional/markers/test_skip_if_not_root.py b/tests/functional/markers/test_skip_if_not_root.py +deleted file mode 100644 +index 140d045..0000000 +--- a/tests/functional/markers/test_skip_if_not_root.py ++++ /dev/null +@@ -1,74 +0,0 @@ +-""" +- tests.functional.markers.test_skip_if_not_root +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_if_not_root`` marker +-""" +-import sys +-from unittest import mock +- +- +-def test_skip_if_not_root_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_if_not_root +- def test_one(): +- assert True +- """ +- ) +- if not sys.platform.startswith("win"): +- mocked_func = mock.patch("os.getuid", return_value=1000) +- else: +- mocked_func = mock.patch("salt.utils.win_functions.is_admin", return_value=False) +- +- with mocked_func: +- res = pytester.runpytest() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_if_not_root_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_if_not_root +- def test_one(): +- assert True +- """ +- ) +- if not sys.platform.startswith("win"): +- mocked_func = mock.patch("os.getuid", return_value=0) +- else: +- mocked_func = mock.patch("salt.utils.win_functions.is_admin", return_value=True) +- +- with mocked_func: +- res = pytester.runpytest_inprocess("-ra", "-vv") +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_error_on_args_or_kwargs(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_if_not_root("arg") +- def test_one(): +- assert True +- +- @pytest.mark.skip_if_not_root(kwarg="arg") +- def test_two(): +- assert True +- """ +- ) +- res = pytester.runpytest("--run-destructive") +- res.assert_outcomes(errors=2) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: The 'skip_if_not_root' marker does not accept any arguments or keyword arguments*" +- ] +- ) +diff --git a/tests/functional/markers/test_skip_on_aarch64.py b/tests/functional/markers/test_skip_on_aarch64.py +deleted file mode 100644 +index 73d062e..0000000 +--- a/tests/functional/markers/test_skip_on_aarch64.py ++++ /dev/null +@@ -1,55 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_aarch64 +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_aarch64`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_aarch64 +- def test_one(): +- assert True +- """ +- ) +- with mock.patch("saltfactories.utils.platform.is_aarch64", return_value=True): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_aarch64 +- def test_one(): +- assert True +- """ +- ) +- with mock.patch("saltfactories.utils.platform.is_aarch64", return_value=False): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_aarch64(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- with mock.patch("saltfactories.utils.platform.is_aarch64", return_value=True): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_aix.py b/tests/functional/markers/test_skip_on_aix.py +deleted file mode 100644 +index d366d26..0000000 +--- a/tests/functional/markers/test_skip_on_aix.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_aix +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_aix`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_aix +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_aix", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_aix +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_aix", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_aix(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_aix", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_darwin.py b/tests/functional/markers/test_skip_on_darwin.py +deleted file mode 100644 +index 577a6de..0000000 +--- a/tests/functional/markers/test_skip_on_darwin.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_darwin +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_darwin`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_darwin +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_darwin", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_darwin +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_darwin", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_darwin(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_darwin", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_freebsd.py b/tests/functional/markers/test_skip_on_freebsd.py +deleted file mode 100644 +index 43edbd0..0000000 +--- a/tests/functional/markers/test_skip_on_freebsd.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_freebsd +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_freebsd`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_freebsd +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_freebsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_freebsd +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_freebsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_freebsd(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_freebsd", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_linux.py b/tests/functional/markers/test_skip_on_linux.py +deleted file mode 100644 +index 0167247..0000000 +--- a/tests/functional/markers/test_skip_on_linux.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_linux +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_linux`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_linux +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_linux", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_linux +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_linux", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_linux(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_linux", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_netbsd.py b/tests/functional/markers/test_skip_on_netbsd.py +deleted file mode 100644 +index 8664942..0000000 +--- a/tests/functional/markers/test_skip_on_netbsd.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_netbsd +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_netbsd`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_netbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_netbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_netbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_netbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_netbsd(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_netbsd", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_openbsd.py b/tests/functional/markers/test_skip_on_openbsd.py +deleted file mode 100644 +index ba4273a..0000000 +--- a/tests/functional/markers/test_skip_on_openbsd.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_openbsd +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_openbsd`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_openbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_openbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_openbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_openbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_openbsd(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_openbsd", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_platforms.py b/tests/functional/markers/test_skip_on_platforms.py +deleted file mode 100644 +index ec6de23..0000000 +--- a/tests/functional/markers/test_skip_on_platforms.py ++++ /dev/null +@@ -1,128 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_platforms +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_platforms`` marker +-""" +-from unittest import mock +- +-import pytest +- +- +-@pytest.mark.parametrize( +- "platform", +- ["windows", "linux", "darwin", "sunos", "smartos", "freebsd", "netbsd", "openbsd", "aix"], +-) +-def test_skipped(pytester, platform): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_platforms({}=True) +- def test_one(): +- assert True +- """.format( +- platform +- ) +- ) +- return_value = True +- with mock.patch( +- "saltfactories.utils.platform.is_{}".format(platform), return_value=return_value +- ): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-@pytest.mark.parametrize( +- "platform", +- ["windows", "linux", "darwin", "sunos", "smartos", "freebsd", "netbsd", "openbsd", "aix"], +-) +-def test_not_skipped(pytester, platform): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_platforms({}=True) +- def test_one(): +- assert True +- """.format( +- platform +- ) +- ) +- return_value = False +- with mock.patch( +- "saltfactories.utils.platform.is_{}".format(platform), return_value=return_value +- ): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_platforms(windows=True, reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +- +- +-def test_no_platforms(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_platforms +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess() +- res.stdout.fnmatch_lines( +- ["*UsageError: Pass at least one platform to skip_on_platforms as a keyword argument"] +- ) +- +- +-def test_all_platforms_false(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_platforms(windows=False, linux=False) +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess() +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: Pass at least one platform with a True value to skip_on_platforms as a keyword argument" +- ] +- ) +- +- +-def test_unknown_platform(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_platforms(car=True) +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess() +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: Passed an invalid platform to skip_on_platforms: on_platforms() got an unexpected keyword argument 'car'" +- ] +- ) +diff --git a/tests/functional/markers/test_skip_on_smartos.py b/tests/functional/markers/test_skip_on_smartos.py +deleted file mode 100644 +index 5f746d8..0000000 +--- a/tests/functional/markers/test_skip_on_smartos.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_smartos +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_smartos`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_smartos +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_smartos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_smartos +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_smartos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_smartos(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_smartos", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_sunos.py b/tests/functional/markers/test_skip_on_sunos.py +deleted file mode 100644 +index f94ca1f..0000000 +--- a/tests/functional/markers/test_skip_on_sunos.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_sunos +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_sunos`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_sunos +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_sunos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_sunos +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_sunos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_sunos(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_sunos", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_on_windows.py b/tests/functional/markers/test_skip_on_windows.py +deleted file mode 100644 +index 9e9dc80..0000000 +--- a/tests/functional/markers/test_skip_on_windows.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_on_windows +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_on_windows`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_windows +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_windows +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_on_windows(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_aarch64.py b/tests/functional/markers/test_skip_unless_on_aarch64.py +deleted file mode 100644 +index fe605c2..0000000 +--- a/tests/functional/markers/test_skip_unless_on_aarch64.py ++++ /dev/null +@@ -1,55 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_aarch64 +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_aarch64`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_aarch64 +- def test_one(): +- assert True +- """ +- ) +- with mock.patch("saltfactories.utils.platform.is_aarch64", return_value=False): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_aarch64 +- def test_one(): +- assert True +- """ +- ) +- with mock.patch("saltfactories.utils.platform.is_aarch64", return_value=True): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_aarch64(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- with mock.patch("saltfactories.utils.platform.is_aarch64", return_value=False): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_aix.py b/tests/functional/markers/test_skip_unless_on_aix.py +deleted file mode 100644 +index 8e222d0..0000000 +--- a/tests/functional/markers/test_skip_unless_on_aix.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_aix +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_aix`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_aix +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_aix", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_aix +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_aix", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_aix(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_aix", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_darwin.py b/tests/functional/markers/test_skip_unless_on_darwin.py +deleted file mode 100644 +index b4ee331..0000000 +--- a/tests/functional/markers/test_skip_unless_on_darwin.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_darwin +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_darwin`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_darwin +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_darwin", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_darwin +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_darwin", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_darwin(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_darwin", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_freebsd.py b/tests/functional/markers/test_skip_unless_on_freebsd.py +deleted file mode 100644 +index fb85ce9..0000000 +--- a/tests/functional/markers/test_skip_unless_on_freebsd.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_freebsd +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_freebsd`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_freebsd +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_freebsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_freebsd +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_freebsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_freebsd(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_freebsd", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_linux.py b/tests/functional/markers/test_skip_unless_on_linux.py +deleted file mode 100644 +index 1ce3ed7..0000000 +--- a/tests/functional/markers/test_skip_unless_on_linux.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_linux +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_linux`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_linux +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_linux", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_linux +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_linux", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_linux(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_linux", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_netbsd.py b/tests/functional/markers/test_skip_unless_on_netbsd.py +deleted file mode 100644 +index f07eeb4..0000000 +--- a/tests/functional/markers/test_skip_unless_on_netbsd.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_netbsd +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_netbsd`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_netbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_netbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_netbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_netbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_netbsd(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_netbsd", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_openbsd.py b/tests/functional/markers/test_skip_unless_on_openbsd.py +deleted file mode 100644 +index f28e236..0000000 +--- a/tests/functional/markers/test_skip_unless_on_openbsd.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_openbsd +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_openbsd`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_openbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_openbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_openbsd +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_openbsd", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_openbsd(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_openbsd", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_platforms.py b/tests/functional/markers/test_skip_unless_on_platforms.py +deleted file mode 100644 +index c42f4b9..0000000 +--- a/tests/functional/markers/test_skip_unless_on_platforms.py ++++ /dev/null +@@ -1,130 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_platforms +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_platforms`` marker +-""" +-from unittest import mock +- +-import pytest +- +- +-@pytest.mark.parametrize( +- "platform", +- ["windows", "linux", "darwin", "sunos", "smartos", "freebsd", "netbsd", "openbsd", "aix"], +-) +-def test_skipped(pytester, platform): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_platforms({}=True) +- def test_one(): +- assert True +- """.format( +- platform +- ) +- ) +- return_value = False +- with mock.patch( +- "saltfactories.utils.platform.is_{}".format(platform), return_value=return_value +- ): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-@pytest.mark.parametrize( +- "platform", +- ["windows", "linux", "darwin", "sunos", "smartos", "freebsd", "netbsd", "openbsd", "aix"], +-) +-def test_not_skipped(pytester, platform): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_platforms({}=True) +- def test_one(): +- assert True +- """.format( +- platform +- ) +- ) +- return_value = True +- with mock.patch( +- "saltfactories.utils.platform.is_{}".format(platform), return_value=return_value +- ): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_platforms(windows=True, reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +- +- +-def test_no_platforms(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_platforms +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess() +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: Pass at least one platform to skip_unless_on_platforms as a keyword argument" +- ] +- ) +- +- +-def test_all_platforms_false(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_platforms(windows=False, linux=False) +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess() +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: Pass at least one platform with a True value to skip_unless_on_platforms as a keyword argument" +- ] +- ) +- +- +-def test_unknown_platform(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_platforms(car=True) +- def test_one(): +- assert True +- """ +- ) +- res = pytester.runpytest_inprocess() +- res.stdout.fnmatch_lines( +- [ +- "*UsageError: Passed an invalid platform to skip_unless_on_platforms: on_platforms() got an unexpected keyword argument 'car'" +- ] +- ) +diff --git a/tests/functional/markers/test_skip_unless_on_smartos.py b/tests/functional/markers/test_skip_unless_on_smartos.py +deleted file mode 100644 +index 430910f..0000000 +--- a/tests/functional/markers/test_skip_unless_on_smartos.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_smartos +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_smartos`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_smartos +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_smartos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_smartos +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_smartos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_smartos(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_smartos", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_sunos.py b/tests/functional/markers/test_skip_unless_on_sunos.py +deleted file mode 100644 +index 56244bd..0000000 +--- a/tests/functional/markers/test_skip_unless_on_sunos.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_sunos +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_sunos`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_sunos +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_sunos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_sunos +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_sunos", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_sunos(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_sunos", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/markers/test_skip_unless_on_windows.py b/tests/functional/markers/test_skip_unless_on_windows.py +deleted file mode 100644 +index 0fb7a21..0000000 +--- a/tests/functional/markers/test_skip_unless_on_windows.py ++++ /dev/null +@@ -1,58 +0,0 @@ +-""" +- tests.functional.markers.test_skip_unless_on_windows +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the ``@pytest.mark.skip_unless_on_windows`` marker +-""" +-from unittest import mock +- +- +-def test_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_windows +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(skipped=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_not_skipped(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_windows +- def test_one(): +- assert True +- """ +- ) +- return_value = True +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess() +- res.assert_outcomes(passed=1) +- res.stdout.no_fnmatch_line("*PytestUnknownMarkWarning*") +- +- +-def test_skip_reason(pytester): +- pytester.makepyfile( +- """ +- import pytest +- +- @pytest.mark.skip_unless_on_windows(reason='Because!') +- def test_one(): +- assert True +- """ +- ) +- return_value = False +- with mock.patch("saltfactories.utils.platform.is_windows", return_value=return_value): +- res = pytester.runpytest_inprocess("-ra", "-s", "-vv") +- res.assert_outcomes(skipped=1) +- res.stdout.fnmatch_lines(["SKIPPED * test_skip_reason.py:*: Because!"]) +diff --git a/tests/functional/utils/saltext/test_log_handlers.py b/tests/functional/utils/saltext/test_log_handlers.py +index 5bf2fe7..cc82685 100644 +--- a/tests/functional/utils/saltext/test_log_handlers.py ++++ b/tests/functional/utils/saltext/test_log_handlers.py +@@ -4,8 +4,8 @@ from datetime import datetime + from datetime import timedelta + + import pytest ++import pytestskipmarkers.utils.platform + +-import saltfactories.utils.platform + from saltfactories.bases import Process + from saltfactories.exceptions import FactoryTimeout + +@@ -155,9 +155,9 @@ def test_all_messages_received_multiprocessing(tempfiles, salt_factories, caplog + # The purpose of this test is just to make sure if forked/spawned processes inherit the + # ZMQHandler and continue logging + if fork_method == "fork": +- if saltfactories.utils.platform.is_windows(): ++ if pytestskipmarkers.utils.platform.is_windows(): + pytest.skip("Start method '{}' is not supported on Windows".format(fork_method)) +- if sys.version_info >= (3, 8) and saltfactories.utils.platform.is_darwin(): ++ if sys.version_info >= (3, 8) and pytestskipmarkers.utils.platform.is_darwin(): + pytest.skip( + "Start method '{}' is not supported on Darwin on Py3.8+".format(fork_method) + ) +diff --git a/tests/integration/factories/daemons/proxy/test_proxy_minion.py b/tests/integration/factories/daemons/proxy/test_proxy_minion.py +index 926e6ac..84d2783 100644 +--- a/tests/integration/factories/daemons/proxy/test_proxy_minion.py ++++ b/tests/integration/factories/daemons/proxy/test_proxy_minion.py +@@ -1,14 +1,15 @@ + import sys + + import pytest ++from pytestskipmarkers.utils import platform + +-from saltfactories.utils import platform + from saltfactories.utils import random_string + +-pytestmark = pytest.mark.skipif( +- sys.platform.lower().startswith("win"), +- reason="Disabled on windows because of multiprocessing pickle spawning issues", +-) ++pytestmark = [ ++ pytest.mark.skip_on_windows( ++ reason="Disabled on windows because of multiprocessing pickle spawning issues", ++ ), ++] + + + @pytest.fixture(scope="module") +diff --git a/tests/integration/factories/daemons/proxy/test_restarts.py b/tests/integration/factories/daemons/proxy/test_restarts.py +index 22ef97d..a243c6d 100644 +--- a/tests/integration/factories/daemons/proxy/test_restarts.py ++++ b/tests/integration/factories/daemons/proxy/test_restarts.py +@@ -1,13 +1,12 @@ +-import sys +- + import pytest + + from saltfactories.utils import random_string + +-pytestmark = pytest.mark.skipif( +- sys.platform.lower().startswith("win"), +- reason="Disabled on windows because of multiprocessing pickle spawning issues", +-) ++pytestmark = [ ++ pytest.mark.skip_on_windows( ++ reason="Disabled on windows because of multiprocessing pickle spawning issues", ++ ), ++] + + + @pytest.fixture(scope="module") +diff --git a/tests/unit/utils/markers/test_skip_if_binaries_missing.py b/tests/unit/utils/markers/test_skip_if_binaries_missing.py +deleted file mode 100644 +index 9cb790d..0000000 +--- a/tests/unit/utils/markers/test_skip_if_binaries_missing.py ++++ /dev/null +@@ -1,72 +0,0 @@ +-""" +- tests.unit.utils.markers.test_skip_if_binaries_missing +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the "skip_if_binaries_missing" marker helper +-""" +-import os +-import sys +- +-import pytest +- +-import saltfactories.utils.markers as markers +- +- +-@pytest.fixture +-def python_binary(): +- return os.path.basename(sys.executable) +- +- +-def test_single_existing(python_binary): +- assert markers.skip_if_binaries_missing([python_binary]) is None +- +- +-def test_multiple_existing(python_binary): +- assert markers.skip_if_binaries_missing([python_binary, "pip"]) is None +- +- +-def test_single_non_existing_with_message(): +- reason = markers.skip_if_binaries_missing(["python9"], reason="Dam!") +- assert reason is not None +- assert reason == "Dam!" +- +- +-def test_multiple_one_missing(python_binary): +- reason = markers.skip_if_binaries_missing([python_binary, "pip9"]) +- assert reason is not None +- assert reason == "The 'pip9' binary was not found" +- +- +-def test_multiple_all_missing(): +- reason = markers.skip_if_binaries_missing(["python9", "pip9"]) +- assert reason is not None +- assert reason == "The 'python9' binary was not found" +- +- +-def test_multiple_one_missing_check_all_false(python_binary): +- reason = markers.skip_if_binaries_missing([python_binary, "pip9"], check_all=False) +- # We should get no message back because the python binary is found +- assert reason is None, reason +- reason = markers.skip_if_binaries_missing(["python9", "pip"], check_all=False) +- # We should get no message back because the pip binary is found +- assert reason is None, reason +- +- +-def test_multiple_one_missing_check_all_false_with_message(python_binary): +- reason = markers.skip_if_binaries_missing( +- [python_binary, "pip9"], reason="Dam!", check_all=False +- ) +- # We should get no message back because the python binary is found +- assert reason is None +- +- +-def test_multiple_missing_check_all_false(): +- reason = markers.skip_if_binaries_missing(["python9", "pip9"], check_all=False) +- assert reason is not None +- assert reason == "None of the following binaries was found: python9, pip9" +- +- +-def test_multiple_missing_check_all_false_with_message(): +- reason = markers.skip_if_binaries_missing(["python9", "pip9"], reason="Dam!", check_all=False) +- assert reason is not None +- assert reason == "Dam!" +diff --git a/tests/unit/utils/markers/test_skip_if_no_local_network.py b/tests/unit/utils/markers/test_skip_if_no_local_network.py +deleted file mode 100644 +index 0b3834a..0000000 +--- a/tests/unit/utils/markers/test_skip_if_no_local_network.py ++++ /dev/null +@@ -1,28 +0,0 @@ +-""" +- tests.unit.utils.markers.test_skip_if_no_local_network +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the "skip_if_no_local_network" marker helper +-""" +-from unittest import mock +- +-import saltfactories.utils.markers as markers +-from saltfactories.utils import ports +-from saltfactories.utils import socket +- +- +-def test_has_local_network(): +- assert markers.skip_if_no_local_network() is None +- +- +-def test_no_local_network(): +- mock_socket = mock.MagicMock() +- mock_socket.bind = mock.MagicMock(side_effect=socket.error) +- with mock.patch( +- "saltfactories.utils.ports.get_unused_localhost_port", +- side_effect=[ports.get_unused_localhost_port() for n in range(10)], +- ): +- with mock.patch("saltfactories.utils.markers.socket.socket", return_value=mock_socket): +- skip_reason = markers.skip_if_no_local_network() +- assert skip_reason is not None +- assert skip_reason == "No local network was detected" +diff --git a/tests/unit/utils/markers/test_skip_if_no_remote_network.py b/tests/unit/utils/markers/test_skip_if_no_remote_network.py +deleted file mode 100644 +index 1aa72dc..0000000 +--- a/tests/unit/utils/markers/test_skip_if_no_remote_network.py ++++ /dev/null +@@ -1,23 +0,0 @@ +-""" +- tests.unit.utils.markers.test_skip_if_no_remote_network +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the "skip_if_no_remote_network" marker helper +-""" +-from unittest import mock +- +-import saltfactories.utils.markers as markers +-from saltfactories.utils import socket +- +- +-def test_has_remote_network(): +- assert markers.skip_if_no_remote_network() is None +- +- +-def test_no_remote_network(): +- mock_socket = mock.MagicMock() +- mock_socket.connect = mock.MagicMock(side_effect=socket.error) +- with mock.patch("saltfactories.utils.markers.socket.socket", return_value=mock_socket): +- skip_reason = markers.skip_if_no_remote_network() +- assert skip_reason is not None +- assert skip_reason == "No internet network connection was detected" +diff --git a/tests/unit/utils/markers/test_skip_if_not_root.py b/tests/unit/utils/markers/test_skip_if_not_root.py +deleted file mode 100644 +index ff955cc..0000000 +--- a/tests/unit/utils/markers/test_skip_if_not_root.py ++++ /dev/null +@@ -1,28 +0,0 @@ +-""" +- tests.unit.utils.markers.test_skip_if_not_root +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Test the "skip_if_not_root" marker helper +-""" +-import sys +-from unittest import mock +- +-import saltfactories.utils.markers +- +- +-def test_when_root(): +- if sys.platform.startswith("win"): +- with mock.patch("salt.utils.win_functions.is_admin", return_value=True): +- assert saltfactories.utils.markers.skip_if_not_root() is None +- else: +- with mock.patch("os.getuid", return_value=0): +- assert saltfactories.utils.markers.skip_if_not_root() is None +- +- +-def test_when_not_root(): +- if sys.platform.startswith("win"): +- with mock.patch("salt.utils.win_functions.is_admin", return_value=False): +- assert saltfactories.utils.markers.skip_if_not_root() is not None +- else: +- with mock.patch("os.getuid", return_value=1): +- assert saltfactories.utils.markers.skip_if_not_root() is not None +diff --git a/tests/unit/utils/test_platforms.py b/tests/unit/utils/test_platforms.py +deleted file mode 100644 +index 8933e54..0000000 +--- a/tests/unit/utils/test_platforms.py ++++ /dev/null +@@ -1,129 +0,0 @@ +-""" +- tests.unit.utils.test_platforms +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- +- Tests for saltfactories.utils.platforms +-""" +-from unittest import mock +- +-import saltfactories.utils.platform +- +- +-def test_is_windows(): +- return_value = True +- with mock.patch("salt.utils.platform.is_windows", return_value=return_value): +- assert saltfactories.utils.platform.is_windows() is return_value +- +- +-def test_is_not_windows(): +- return_value = True +- with mock.patch("salt.utils.platform.is_windows", return_value=return_value): +- assert saltfactories.utils.platform.is_windows() is return_value +- +- +-def test_is_linux(): +- return_value = True +- with mock.patch("salt.utils.platform.is_linux", return_value=return_value): +- assert saltfactories.utils.platform.is_linux() is return_value +- +- +-def test_is_not_linux(): +- return_value = True +- with mock.patch("salt.utils.platform.is_linux", return_value=return_value): +- assert saltfactories.utils.platform.is_linux() is return_value +- +- +-def test_is_darwin(): +- return_value = True +- with mock.patch("salt.utils.platform.is_darwin", return_value=return_value): +- assert saltfactories.utils.platform.is_darwin() is return_value +- +- +-def test_is_not_darwin(): +- return_value = True +- with mock.patch("salt.utils.platform.is_darwin", return_value=return_value): +- assert saltfactories.utils.platform.is_darwin() is return_value +- +- +-def test_is_sunos(): +- return_value = True +- with mock.patch("salt.utils.platform.is_sunos", return_value=return_value): +- assert saltfactories.utils.platform.is_sunos() is return_value +- +- +-def test_is_not_sunos(): +- return_value = True +- with mock.patch("salt.utils.platform.is_sunos", return_value=return_value): +- assert saltfactories.utils.platform.is_sunos() is return_value +- +- +-def test_is_smartos(): +- return_value = True +- with mock.patch("salt.utils.platform.is_smartos", return_value=return_value): +- assert saltfactories.utils.platform.is_smartos() is return_value +- +- +-def test_is_not_smartos(): +- return_value = True +- with mock.patch("salt.utils.platform.is_smartos", return_value=return_value): +- assert saltfactories.utils.platform.is_smartos() is return_value +- +- +-def test_is_freebsd(): +- return_value = True +- with mock.patch("salt.utils.platform.is_freebsd", return_value=return_value): +- assert saltfactories.utils.platform.is_freebsd() is return_value +- +- +-def test_is_not_freebsd(): +- return_value = True +- with mock.patch("salt.utils.platform.is_freebsd", return_value=return_value): +- assert saltfactories.utils.platform.is_freebsd() is return_value +- +- +-def test_is_netbsd(): +- return_value = True +- with mock.patch("salt.utils.platform.is_netbsd", return_value=return_value): +- assert saltfactories.utils.platform.is_netbsd() is return_value +- +- +-def test_is_not_netbsd(): +- return_value = True +- with mock.patch("salt.utils.platform.is_netbsd", return_value=return_value): +- assert saltfactories.utils.platform.is_netbsd() is return_value +- +- +-def test_is_openbsd(): +- return_value = True +- with mock.patch("salt.utils.platform.is_openbsd", return_value=return_value): +- assert saltfactories.utils.platform.is_openbsd() is return_value +- +- +-def test_is_not_openbsd(): +- return_value = True +- with mock.patch("salt.utils.platform.is_openbsd", return_value=return_value): +- assert saltfactories.utils.platform.is_openbsd() is return_value +- +- +-def test_is_aix(): +- return_value = True +- with mock.patch("salt.utils.platform.is_aix", return_value=return_value): +- assert saltfactories.utils.platform.is_aix() is return_value +- +- +-def test_is_not_aix(): +- return_value = True +- with mock.patch("salt.utils.platform.is_aix", return_value=return_value): +- assert saltfactories.utils.platform.is_aix() is return_value +- +- +-def test_is_aarch64(): +- return_value = True +- with mock.patch("sys.platform", "aarch64"): +- assert saltfactories.utils.platform.is_aarch64() is return_value +- +- +-def test_is_not_aarch64(): +- return_value = False +- with mock.patch("sys.platform", "not_aarch64"): +- assert saltfactories.utils.platform.is_aarch64() is return_value diff -Nru pytest-salt-factories-0.907.0/debian/rules pytest-salt-factories-0.907.0/debian/rules --- pytest-salt-factories-0.907.0/debian/rules 2021-10-26 17:02:23.000000000 +0000 +++ pytest-salt-factories-0.907.0/debian/rules 2022-04-15 22:20:46.000000000 +0000 @@ -3,7 +3,6 @@ %: dh $@ --buildsystem=pybuild --with python3 +# Do not run test cases during package build and only rely on autopkgtest +# because the test suite relies on salt (and introduces a circular dependency). override_dh_auto_test: -ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) - PYTHONPATH=src python3 -m pytest -ra tests/functional tests/unit -endif