|
1 | 1 | import pytest
|
2 |
| -import warnings |
3 | 2 |
|
4 | 3 |
|
5 |
| -def test_padic_lattice_element(): |
| 4 | +@pytest.fixture |
| 5 | +def R1(): |
| 6 | + from warnings import catch_warnings, filterwarnings |
| 7 | + from sage.rings.padics.factory import ZpLC |
| 8 | + with catch_warnings(category=FutureWarning): |
| 9 | + filterwarnings("ignore", category=FutureWarning) |
| 10 | + return ZpLC(2) |
| 11 | + |
| 12 | + |
| 13 | +@pytest.fixture |
| 14 | +def R2(): |
| 15 | + from warnings import catch_warnings, filterwarnings |
| 16 | + from sage.rings.padics.factory import ZpLF |
| 17 | + with catch_warnings(category=FutureWarning): |
| 18 | + filterwarnings("ignore", category=FutureWarning) |
| 19 | + return ZpLF(2) |
| 20 | + |
| 21 | + |
| 22 | +@pytest.fixture |
| 23 | +def R3(): |
| 24 | + from warnings import catch_warnings, filterwarnings |
| 25 | + from sage.rings.padics.factory import QpLC |
| 26 | + with catch_warnings(category=FutureWarning): |
| 27 | + filterwarnings("ignore", category=FutureWarning) |
| 28 | + return QpLC(2) |
| 29 | + |
| 30 | + |
| 31 | +@pytest.fixture |
| 32 | +def R4(): |
| 33 | + from warnings import catch_warnings, filterwarnings |
| 34 | + from sage.rings.padics.factory import QpLF |
| 35 | + with catch_warnings(category=FutureWarning): |
| 36 | + filterwarnings("ignore", category=FutureWarning) |
| 37 | + return QpLF(2) |
| 38 | + |
| 39 | + |
| 40 | +# Use strings for the fixture names here, and then later convert them |
| 41 | +# to the actual fixture objects using request.getfixturevalue(). This |
| 42 | +# is a workaround for being unable to pass fixtures directly as |
| 43 | +# parameters: |
| 44 | +# |
| 45 | +# https://github.com/pytest-dev/pytest/issues/349 |
| 46 | +# |
| 47 | +elements = ( "R1", "R2", "R3", "R4" ) |
| 48 | + |
| 49 | + |
| 50 | +@pytest.mark.parametrize("e", elements) |
| 51 | +def test_padic_lattice_element(e, request): |
6 | 52 | r"""
|
7 | 53 | Run the ``TestSuite()`` for some examples that previously
|
8 | 54 | lived in the TESTS:: block of the padic_lattice_element module.
|
9 | 55 | """
|
10 | 56 | from sage.misc.sage_unittest import TestSuite
|
11 |
| - from sage.rings.padics.factory import ZpLC, ZpLF, QpLC, QpLF |
12 |
| - |
13 |
| - with warnings.catch_warnings(category=FutureWarning): |
14 |
| - warnings.filterwarnings("ignore", category=FutureWarning) |
15 |
| - # These all raise FutureWarnings |
16 |
| - R1 = ZpLC(2) |
17 |
| - R2 = ZpLF(2) |
18 |
| - R3 = QpLC(2) |
19 |
| - R4 = QpLF(2) |
20 |
| - |
21 |
| - for R in (R1, R2, R3, R4): |
22 |
| - # Only do a few runs, _test_matrix_smith() in particular is |
23 |
| - # sloooooow. |
24 |
| - TestSuite(R).run(verbose=True, |
25 |
| - raise_on_failure=True, |
26 |
| - skip="_test_teichmuller", |
27 |
| - max_runs=8) |
| 57 | + |
| 58 | + # Convert the string to a real fixture |
| 59 | + e = request.getfixturevalue(e) |
| 60 | + |
| 61 | + # Only do a few runs, _test_matrix_smith() in particular is slow. |
| 62 | + TestSuite(e).run(verbose=True, |
| 63 | + raise_on_failure=True, |
| 64 | + skip="_test_teichmuller", |
| 65 | + max_runs=8) |
0 commit comments