Use the plus/minus unicode symbol in the repr string.

This was a challenge because it had to work in python2 and python3,
which have almost opposite unicode models, and I couldn't use the six
library.  I'm also not sure the solution I found would work in python3
before python3.3, because I use the u'' string prefix which I think was
initially not part of python3.
This commit is contained in:
Kale Kundert
2016-03-07 16:40:41 -08:00
parent dd28e28b34
commit bf97d5b817
2 changed files with 6 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ class TestApprox:
runner.run(test)
def test_repr_string(self):
# Just make sure the Unicode handling doesn't raise any exceptions.
print(pytest.approx(1.0))
assert repr(pytest.approx(1.0)) == '1.0 ± 1.0e-06'
print(pytest.approx([1.0, 2.0, 3.0]))