Skip to content

Commit 7d90e7f

Browse files
committed
fix tests for older python versions
1 parent bdd0c70 commit 7d90e7f

File tree

9 files changed

+161
-330
lines changed

9 files changed

+161
-330
lines changed

src/mxdev/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .processing import read # noqa
88
from .state import State # noqa
99

10+
1011
try:
1112
from ._version import __version__
1213
except ImportError:

tests/test_config.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def test_configuration_basic():
4242
assert config.settings["requirements-out"] == "requirements-mxdev.txt"
4343
assert config.settings["constraints-out"] == "constraints-mxdev.txt"
4444
assert "example.package" in config.packages
45-
assert config.packages["example.package"]["url"] == "https://github.com/example/package.git"
45+
assert (
46+
config.packages["example.package"]["url"]
47+
== "https://github.com/example/package.git"
48+
)
4649
assert config.packages["example.package"]["branch"] == "main"
4750

4851

@@ -136,8 +139,7 @@ def test_configuration_override_args_offline():
136139

137140
base = pathlib.Path(__file__).parent / "data" / "config_samples"
138141
config = Configuration(
139-
str(base / "basic_config.ini"),
140-
override_args={"offline": True}
142+
str(base / "basic_config.ini"), override_args={"offline": True}
141143
)
142144

143145
assert config.settings["offline"] == "true"
@@ -151,8 +153,7 @@ def test_configuration_override_args_threads():
151153

152154
base = pathlib.Path(__file__).parent / "data" / "config_samples"
153155
config = Configuration(
154-
str(base / "basic_config.ini"),
155-
override_args={"threads": 16}
156+
str(base / "basic_config.ini"), override_args={"threads": 16}
156157
)
157158

158159
assert config.settings["threads"] == "16"

tests/test_entry_points.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def test_load_eps_by_group_with_python312():
2121
mock_ep2.name = "test-ep2"
2222
mock_eps = [mock_ep1, mock_ep2]
2323

24-
with patch('mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS', True):
25-
with patch('mxdev.entry_points.entry_points', return_value=mock_eps) as mock_entry_points:
24+
with patch("mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS", True):
25+
with patch(
26+
"mxdev.entry_points.entry_points", return_value=mock_eps
27+
) as mock_entry_points:
2628
result = load_eps_by_group("test-group")
2729

2830
# Should call entry_points with group parameter
@@ -43,13 +45,12 @@ def test_load_eps_by_group_with_old_python():
4345
mock_ep2 = MagicMock()
4446
mock_ep2.name = "test-ep2"
4547

46-
mock_eps_dict = {
47-
"test-group": [mock_ep1, mock_ep2],
48-
"other-group": []
49-
}
48+
mock_eps_dict = {"test-group": [mock_ep1, mock_ep2], "other-group": []}
5049

51-
with patch('mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS', False):
52-
with patch('mxdev.entry_points.entry_points', return_value=mock_eps_dict) as mock_entry_points:
50+
with patch("mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS", False):
51+
with patch(
52+
"mxdev.entry_points.entry_points", return_value=mock_eps_dict
53+
) as mock_entry_points:
5354
result = load_eps_by_group("test-group")
5455

5556
# Should call entry_points without parameters
@@ -64,12 +65,10 @@ def test_load_eps_by_group_group_not_found():
6465
"""Test load_eps_by_group when group doesn't exist (old Python API)."""
6566
from mxdev.entry_points import load_eps_by_group
6667

67-
mock_eps_dict = {
68-
"other-group": []
69-
}
68+
mock_eps_dict = {"other-group": []}
7069

71-
with patch('mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS', False):
72-
with patch('mxdev.entry_points.entry_points', return_value=mock_eps_dict):
70+
with patch("mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS", False):
71+
with patch("mxdev.entry_points.entry_points", return_value=mock_eps_dict):
7372
result = load_eps_by_group("nonexistent-group")
7473

7574
# Should return empty list when group not found
@@ -87,8 +86,8 @@ def test_load_eps_by_group_deduplicates():
8786
mock_ep.__hash__ = lambda self: hash("test-ep")
8887
mock_eps = [mock_ep, mock_ep] # Duplicate
8988

90-
with patch('mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS', True):
91-
with patch('mxdev.entry_points.entry_points', return_value=mock_eps):
89+
with patch("mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS", True):
90+
with patch("mxdev.entry_points.entry_points", return_value=mock_eps):
9291
result = load_eps_by_group("test-group")
9392

9493
# Should deduplicate - only one entry
@@ -100,8 +99,8 @@ def test_load_eps_by_group_empty_group():
10099
"""Test load_eps_by_group with empty group results."""
101100
from mxdev.entry_points import load_eps_by_group
102101

103-
with patch('mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS', True):
104-
with patch('mxdev.entry_points.entry_points', return_value=[]):
102+
with patch("mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS", True):
103+
with patch("mxdev.entry_points.entry_points", return_value=[]):
105104
result = load_eps_by_group("empty-group")
106105

107106
# Should return empty list
@@ -112,12 +111,10 @@ def test_load_eps_by_group_old_python_empty_group():
112111
"""Test load_eps_by_group with empty group on old Python API."""
113112
from mxdev.entry_points import load_eps_by_group
114113

115-
mock_eps_dict = {
116-
"test-group": []
117-
}
114+
mock_eps_dict = {"test-group": []}
118115

119-
with patch('mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS', False):
120-
with patch('mxdev.entry_points.entry_points', return_value=mock_eps_dict):
116+
with patch("mxdev.entry_points.HAS_IMPORTLIB_ENTRYPOINTS", False):
117+
with patch("mxdev.entry_points.entry_points", return_value=mock_eps_dict):
121118
result = load_eps_by_group("test-group")
122119

123120
# Should return empty list

0 commit comments

Comments
 (0)