Skip to content

Commit cb87d0a

Browse files
tests.helpers.RunConditions is added
RunConditions contains the code to check the execution condition of tests. It is used in TestLocalOperations.
1 parent 1c64337 commit cb87d0a

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

tests/__init__.py

Whitespace-only changes.

tests/helpers/__init__.py

Whitespace-only changes.

tests/helpers/run_conditions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
import platform
3+
4+
5+
class RunConditions:
6+
# It is not a test kit!
7+
__test__ = False
8+
9+
def skip_if_windows():
10+
if platform.system().lower() == "windows":
11+
pytest.skip("This test does not support Windows.")

tests/test_local.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
import pytest
2-
import platform
32

43
from testgres import ExecUtilException
54
from testgres import LocalOperations
65

6+
from .helpers.run_conditions import RunConditions
7+
78

89
class TestLocalOperations:
910

1011
@pytest.fixture(scope="function", autouse=True)
1112
def setup(self):
1213
self.operations = LocalOperations()
1314

14-
def skip_if_windows():
15-
if platform.system().lower() == "windows":
16-
pytest.skip("This test does not support Windows.")
17-
1815
def test_exec_command_success(self):
1916
"""
2017
Test exec_command for successful command execution.
2118
"""
22-
__class__.skip_if_windows()
19+
RunConditions.skip_if_windows()
2320

2421
cmd = "python3 --version"
2522
response = self.operations.exec_command(cmd, wait_exit=True, shell=True)
@@ -30,7 +27,7 @@ def test_exec_command_failure(self):
3027
"""
3128
Test exec_command for command execution failure.
3229
"""
33-
__class__.skip_if_windows()
30+
RunConditions.skip_if_windows()
3431

3532
cmd = "nonexistent_command"
3633
while True:
@@ -46,7 +43,7 @@ def test_exec_command_failure__expect_error(self):
4643
"""
4744
Test exec_command for command execution failure.
4845
"""
49-
__class__.skip_if_windows()
46+
RunConditions.skip_if_windows()
5047

5148
cmd = "nonexistent_command"
5249

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy