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:
@@ -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]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user