tests: lazily import doctest in approx tests

This commit is contained in:
Daniel Hahler 2019-10-27 02:37:13 +02:00
parent 32412532ef
commit a5bd19e3b4
1 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,3 @@
import doctest
import operator import operator
from decimal import Decimal from decimal import Decimal
from fractions import Fraction from fractions import Fraction
@ -13,12 +12,14 @@ inf, nan = float("inf"), float("nan")
@pytest.fixture @pytest.fixture
def mocked_doctest_runner(monkeypatch): def mocked_doctest_runner(monkeypatch):
import doctest
class MockedPdb: class MockedPdb:
def __init__(self, out): def __init__(self, out):
pass pass
def set_trace(self): def set_trace(self):
pass raise NotImplementedError("not used")
def reset(self): def reset(self):
pass pass
@ -428,6 +429,8 @@ class TestApprox:
assert a21 != approx(a12) assert a21 != approx(a12)
def test_doctests(self, mocked_doctest_runner): def test_doctests(self, mocked_doctest_runner):
import doctest
parser = doctest.DocTestParser() parser = doctest.DocTestParser()
test = parser.get_doctest( test = parser.get_doctest(
approx.__doc__, {"approx": approx}, approx.__name__, None, None approx.__doc__, {"approx": approx}, approx.__name__, None, None