Skip to content

Commit b2784ed

Browse files
committed
Skip tests if current Python version is too old
1 parent cf75cd2 commit b2784ed

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

testing/tests/api/test_commanding.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from pytest import mark
22
from pymol import cmd
3+
import sys
34
from typing import List, Union, Any, Tuple
45
from pathlib import Path
6+
from pymol import test_utils
57

68

79
def test_docstring():
@@ -91,9 +93,12 @@ def func10(a: str="sele"):
9193
out, err = capsys.readouterr()
9294
assert out + err == ''
9395

96+
@mark.skipif(
97+
sys.version_info < (3, 11),
98+
reason="Requires StrEnum of Python 3.11+"
99+
)
94100
def test_str_enum(capsys):
95-
# TODO Fix imports requires
96-
from strenum import StrEnum
101+
from enum import StrEnum
97102
class E(StrEnum):
98103
A = "a"
99104
@cmd.new_command

testing/tests/helpers/test_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import tempfile
23
from PIL import Image
34
import numpy
@@ -131,3 +132,11 @@ def decorator(test_func):
131132
reason=reason or f"Requires PyMOL {version}"
132133
)(test_func)
133134
return decorator
135+
136+
def requires_python(python_version, reason=None):
137+
def decorator(test_func):
138+
return pytest.mark.skipif(
139+
sys.version_info < python_version,
140+
reason=reason
141+
)(test_func)
142+
return decorator

0 commit comments

Comments
 (0)