summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests
diff options
context:
space:
mode:
authorRoss Barnowski <rossbar@berkeley.edu>2020-12-07 15:39:54 -0800
committerRoss Barnowski <rossbar@berkeley.edu>2020-12-07 15:39:54 -0800
commit9235016e44f306b61fcc7805956654f65183c785 (patch)
tree9a85d0aadad23f608a0bf519aefadb93a427cff9 /numpy/polynomial/tests
parentb01a4732cedf8ffe6def3a877e22dacacc796bd5 (diff)
downloadnumpy-9235016e44f306b61fcc7805956654f65183c785.tar.gz
TST: Fix crosstalk issues with polynomial str tests.
Polynomial printing tests implicitly depended on calling order, causing the test suite to fail when the test ordering was randomized with the pytest-random plugin (gh-17954). Two factors contributed to this: * Improper setting of class-level test config and * Poorly designed test that overrode an inherited class variable.
Diffstat (limited to 'numpy/polynomial/tests')
-rw-r--r--numpy/polynomial/tests/test_printing.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/numpy/polynomial/tests/test_printing.py b/numpy/polynomial/tests/test_printing.py
index 27a8ab9f2..4e9902a69 100644
--- a/numpy/polynomial/tests/test_printing.py
+++ b/numpy/polynomial/tests/test_printing.py
@@ -85,7 +85,7 @@ class TestStrUnicodeSuperSubscripts:
class TestStrAscii:
@pytest.fixture(scope='class', autouse=True)
- def use_unicode(self):
+ def use_ascii(self):
poly.set_default_printstyle('ascii')
@pytest.mark.parametrize(('inp', 'tgt'), (
@@ -161,7 +161,10 @@ class TestStrAscii:
class TestLinebreaking:
- poly.set_default_printstyle('ascii')
+
+ @pytest.fixture(scope='class', autouse=True)
+ def use_ascii(self):
+ poly.set_default_printstyle('ascii')
def test_single_line_one_less(self):
# With 'ascii' style, len(str(p)) is default linewidth - 1 (i.e. 74)
@@ -283,19 +286,19 @@ def test_nonnumeric_object_coefficients(coefs, tgt):
class TestFormat:
def test_format_unicode(self):
- poly.Polynomial._use_unicode = False
+ poly.set_default_printstyle('ascii')
p = poly.Polynomial([1, 2, 0, -1])
assert_equal(format(p, 'unicode'), "1.0 + 2.0·x¹ + 0.0·x² - 1.0·x³")
def test_format_ascii(self):
- poly.Polynomial._use_unicode = True
+ poly.set_default_printstyle('unicode')
p = poly.Polynomial([1, 2, 0, -1])
assert_equal(
format(p, 'ascii'), "1.0 + 2.0 x**1 + 0.0 x**2 - 1.0 x**3"
)
def test_empty_formatstr(self):
- poly.Polynomial._use_unicode = False
+ poly.set_default_printstyle('ascii')
p = poly.Polynomial([1, 2, 3])
assert_equal(format(p), "1.0 + 2.0 x**1 + 3.0 x**2")
assert_equal(f"{p}", "1.0 + 2.0 x**1 + 3.0 x**2")