Skip to content

Commit

Permalink
Migrate to pytester: test_capture.py, test_terminal.py, approx.py (#8108
Browse files Browse the repository at this point in the history
)

* Migrate to pytester: test_capture.py, test_config.py, approx.py

* migrate test_terminal.py

* revert test_config.py

* more typing in test_terminal.py

* try-out 'tr' fixture update

* revert 'tr' fixture, update test_config.py
  • Loading branch information
antonblr authored Dec 8, 2020
1 parent 059f6ff commit 810b878
Show file tree
Hide file tree
Showing 4 changed files with 928 additions and 822 deletions.
7 changes: 4 additions & 3 deletions testing/python/approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Optional

import pytest
from _pytest.pytester import Pytester
from pytest import approx

inf, nan = float("inf"), float("nan")
Expand Down Expand Up @@ -456,20 +457,20 @@ def test_doctests(self, mocked_doctest_runner) -> None:
)
mocked_doctest_runner.run(test)

def test_unicode_plus_minus(self, testdir):
def test_unicode_plus_minus(self, pytester: Pytester) -> None:
"""
Comparing approx instances inside lists should not produce an error in the detailed diff.
Integration test for issue #2111.
"""
testdir.makepyfile(
pytester.makepyfile(
"""
import pytest
def test_foo():
assert [3] == [pytest.approx(4)]
"""
)
expected = "4.0e-06"
result = testdir.runpytest()
result = pytester.runpytest()
result.stdout.fnmatch_lines(
[f"*At index 0 diff: 3 != 4 ± {expected}", "=* 1 failed in *="]
)
Expand Down
Loading

0 comments on commit 810b878

Please sign in to comment.