summaryrefslogtreecommitdiff
path: root/dev-python/PyMeeus/files/pytest-7.2.patch
blob: 51534a8bd277d52794cfac1a1247d2f6e8348f0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From f064abfda6b3cb48cb42a6827cd250413056f227 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@debian.org>
Date: Sat, 6 Apr 2024 22:22:52 -0400
Subject: [PATCH] fix pytest 7.2 compatibility

Pytest 7.2 deprecated plain top-level `setup()` and `teardown()`
functions in favor of their own decorators:

https://docs.pytest.org/en/latest/changelog.html#pytest-7-2-0-2022-10-23
https://docs.pytest.org/en/latest/deprecations.html#setup-teardown

Now we need to use module-level setup/teardown, which is extremely
similar, just named differently:

https://docs.pytest.org/en/latest/how-to/xunit_setup.html#module-level-setup-teardown

We keep compatibility shims for older pytest releases.

Closes: #24
---
 tests/test_curvefitting.py  | 10 +++++++---
 tests/test_interpolation.py |  9 +++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/tests/test_curvefitting.py b/tests/test_curvefitting.py
index 9398327..0d20cca 100644
--- a/tests/test_curvefitting.py
+++ b/tests/test_curvefitting.py
@@ -31,9 +31,8 @@
 cf4 = CurveFitting()
 
 
-def setup():
+def setup_module():
     """This function is used to set up the environment for the tests"""
-
     # Set up a few CurveFitting objects
     cf1.set([73.0, 38.0, 35.0, 42.0, 78.0, 68.0, 74.0, 42.0, 52.0, 54.0, 39.0,
              61.0, 42.0, 49.0, 50.0, 62.0, 44.0, 39.0, 43.0, 54.0, 44.0, 37.0],
@@ -58,10 +57,15 @@ def setup():
              -0.8372, -0.4377, -0.3640, -0.3508, -0.2126])
 
 
-def teardown():
+def teardown_module():
     pass
 
 
+# pre pytest 7.2 compatibility
+setup = setup_module
+teardown = teardown_module
+
+
 # CurveFitting class
 
 def test_curvefitting_constructor():
diff --git a/tests/test_interpolation.py b/tests/test_interpolation.py
index e853c37..08f7b6e 100644
--- a/tests/test_interpolation.py
+++ b/tests/test_interpolation.py
@@ -32,7 +32,7 @@
 i_sine = Interpolation()
 
 
-def setup():
+def setup_module():
     """This function is used to set up the environment for the tests"""
     # Set up a interpolation object which uses Right Ascension
     y0 = Angle(10, 18, 48.732, ra=True)
@@ -64,10 +64,15 @@ def setup():
                 0.5236885653, 0.5453707057])
 
 
-def teardown():
+def teardown_module():
     pass
 
 
+# pre pytest 7.2 ompatibility
+setup = setup_module
+teardown = teardown_module
+
+
 # Interpolation class
 
 def test_interpolation_constructor():