Last active
January 2, 2024 16:56
-
-
Save flying-sheep/4ef2072763da268b1b1953e102ad21f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/.*cache/ | |
/__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import warnings | |
import pytest | |
doctest_marker = pytest.mark.usefixtures("suppress_env") | |
@pytest.fixture | |
def suppress_env() -> None: | |
warnings.filterwarnings("ignore", category=FutureWarning) | |
def pytest_itemcollected(item: pytest.Item) -> None: | |
if isinstance(item, pytest.DoctestItem): | |
item.add_marker(doctest_marker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[envs.default] | |
skip-install = true | |
[[envs.default.matrix]] | |
pt = ["7", "8"] | |
[envs.default.overrides] | |
matrix.pt.dependencies = [ | |
{ value = "pytest==7.4.3", if = ["7"] }, | |
{ value = "pytest==8.0.0.rc1", if = ["8"] }, | |
] | |
[envs.default.scripts] | |
test = "pytest -vv --doctest-modules -Werror" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import warnings | |
def has_doctest() -> None: | |
"""Doctest! | |
>>> import warnings | |
>>> warnings.warn("Hi!", FutureWarning) | |
""" | |
def test_warn(suppress_env) -> None: | |
warnings.warn("Hi!", FutureWarning) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment