Skip to content

Commit d51d45a

Browse files
committed
TST: add test that shows __doctest_requires__ fails with contraint
1 parent 0d8d511 commit d51d45a

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

tests/test_doctestplus.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,9 @@ def test_requires_module_variable(testdir):
15651565
__doctest_requires__ = {
15661566
("f",): ["module_that_is_not_availabe"],
15671567
("g",): ["pytest"],
1568+
("h",): ["pytest>=1.0"],
1569+
("i",): ["pytest<1.0"],
1570+
("j",): ["module_that_is_not_availabe>=1.0"],
15681571
}
15691572
15701573
def f():
@@ -1575,13 +1578,38 @@ def f():
15751578
15761579
def g():
15771580
'''
1578-
Test that call to `pytest.importorskip` is not visible
1581+
Make sure out internal variables are not visible.
15791582
1583+
>>> assert "ModuleChecker" not in locals()
15801584
>>> assert "pytest" not in locals()
15811585
>>> assert "___" not in locals()
15821586
>>> 1 + 1
15831587
2
15841588
'''
15851589
pass
1590+
1591+
def h():
1592+
'''
1593+
Make sure out internal variables are not visible.
1594+
1595+
>>> assert "ModuleChecker" not in locals()
1596+
>>> assert "pytest" not in locals()
1597+
>>> assert "___" not in locals()
1598+
>>> 1 + 1
1599+
2
1600+
'''
1601+
pass
1602+
1603+
def i():
1604+
'''
1605+
>>> assert False, "This should be skipped due to version requirement not being met"
1606+
'''
1607+
skip
1608+
1609+
def j():
1610+
'''
1611+
>>> import module_that_is_not_availabe
1612+
'''
1613+
skip
15861614
""")
1587-
testdir.inline_run(p, '--doctest-plus').assertoutcome(passed=1, skipped=1)
1615+
testdir.inline_run(p, '--doctest-plus').assertoutcome(passed=2, skipped=3)

0 commit comments

Comments
 (0)