Skip to content

Commit 55e65fe

Browse files
muxatormuxator
muxator
authored andcommitted
tests: fix PytestRemovedIn8Warning ("support for nose tests is deprecated and will be removed in a future release")
Before this change, the test log contained 37 entries like this: PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release. After this change, on my machine the test log shrinks from 1672 to 1405 lines (16% less). At some point in time, we will migrate to Pytest 8.x, and this would be an hindrance. A reference for the fix can be found at: https://docs.pytest.org/en/stable/deprecations.html#support-for-tests-written-for-nose Affected tests were found with: rg "def (setup|teardown)\(" tests
1 parent c5f8eb7 commit 55e65fe

7 files changed

+8
-8
lines changed

tests/test_calibrator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class TestCalibrate:
119119
],
120120
)
121121

122-
def setup(self) -> None:
122+
def setup_method(self) -> None:
123123
"""Set up the tests."""
124124
self.true_params = np.array([0.50, 0.50])
125125
self.bounds = [

tests/test_losses/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def compute_loss_1d(
6767
sim_data: NDArray[np.float64]
6868
real_data: NDArray[np.float64]
6969

70-
def setup(self) -> None:
70+
def setup_method(self) -> None:
7171
"""Set up the tests."""
7272
self.loss = TestComputeLoss.MyCustomLoss(
7373
self.loss_constant,

tests/test_plot/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ class BasePlotResultsTest(BasePlotTest):
6969
saving_folder: Path
7070

7171
@classmethod
72-
def setup(cls) -> None:
72+
def setup_method(cls) -> None:
7373
"""Set up the test."""
7474
cls.args = [cls.saving_folder, *cls.args]

tests/test_plot/test_plot_descriptive_statistics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TestTsStats(BasePlotTest):
3838
args: Sequence[Any] = ()
3939
expected_image = PLOT_DIR / "ts_stats-expected.png"
4040

41-
def setup(self) -> None:
41+
def setup_method(self) -> None:
4242
"""Set up the test."""
4343
rng = np.random.default_rng(42)
4444
data = rng.random(100)

tests/test_plot/test_plot_results.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_run_by_method_num(self, method_num: int) -> None:
8383
self.args = [self.saving_folder, method_num]
8484
super().run()
8585

86-
def teardown(self) -> None:
86+
def teardown_method(self) -> None:
8787
"""Tear down the test."""
8888
# restore default attributes
8989
delattr(self, "expected_image")
@@ -113,7 +113,7 @@ def test_run_by_batch_num(self, batch_num: int) -> None:
113113
self.args = [self.saving_folder, list(range(batch_num))]
114114
super().run()
115115

116-
def teardown(self) -> None:
116+
def teardown_method(self) -> None:
117117
"""Tear down the test."""
118118
# restore default attributes
119119
delattr(self, "expected_image")

tests/test_samplers/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def sample_batch(
5555
"""Sample a batch of parameters."""
5656
return self.random_generator.random(size=(batch_size, search_space.dims))
5757

58-
def setup(self) -> None:
58+
def setup_method(self) -> None:
5959
"""Set up the tests."""
6060
self.bounds = [[0.10, 0.10, 0.10], [1.00, 1.00, 1.00]]
6161
self.bounds_step = [0.01, 0.01, 0.01]

tests/test_samplers/test_gaussian_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class TestGaussianProcess2D:
3030
"""Test GaussianProcess sampling."""
3131

32-
def setup(self) -> None:
32+
def setup_method(self) -> None:
3333
"""Set up the test."""
3434
self.xys, self.losses = self._construct_fake_grid(seed=0)
3535

0 commit comments

Comments
 (0)