Skip to content

Commit 4b603c1

Browse files
committed
sage.rings.valuation.mapped_valuation_test: parameterize tests
Use parameterized tests and fixtures to improve the reporting from these tests.
1 parent efc9abd commit 4b603c1

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed
Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import pytest
22

33

4-
def test_finite_extension_from_limit_valuation():
5-
r"""
6-
Run the ``TestSuite()`` for two examples given in the
7-
``FiniteExtensionFromLimitValuation`` documentation.
8-
"""
9-
from sage.misc.sage_unittest import TestSuite
4+
@pytest.fixture
5+
def w():
106
from sage.rings.function_field.constructor import FunctionField
117
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
128
from sage.rings.integer import Integer
@@ -18,10 +14,42 @@ def test_finite_extension_from_limit_valuation():
1814
y = R.gen()
1915
L = K.extension(y**2 - x)
2016
v = K.valuation(Integer(1))
21-
w = v.extensions(L)
2217

23-
for ext in w:
24-
# fewer max_runs, these are kind of slow
25-
TestSuite(ext).run(verbose=True,
26-
raise_on_failure=True,
27-
max_runs=512)
18+
return v.extensions(L)
19+
20+
21+
@pytest.fixture
22+
def w0(w):
23+
return w[0]
24+
25+
26+
@pytest.fixture
27+
def w1(w):
28+
return w[1]
29+
30+
31+
# Use strings for the fixture names here, and then later convert them
32+
# to the actual fixture objects using request.getfixturevalue(). This
33+
# is a workaround for being unable to pass fixtures directly as
34+
# parameters:
35+
#
36+
# https://github.com/pytest-dev/pytest/issues/349
37+
#
38+
extensions = ( "w0", "w1" )
39+
40+
41+
@pytest.mark.parametrize("e", extensions)
42+
def test_finite_extension_from_limit_valuation(e, request):
43+
r"""
44+
Run the ``TestSuite()`` for two examples given in the
45+
``FiniteExtensionFromLimitValuation`` documentation.
46+
"""
47+
from sage.misc.sage_unittest import TestSuite
48+
49+
# Convert the string to a real fixture
50+
e = request.getfixturevalue(e)
51+
52+
# fewer max_runs, these are kind of slow
53+
TestSuite(e).run(verbose=True,
54+
raise_on_failure=True,
55+
max_runs=512)

0 commit comments

Comments
 (0)