Skip to content

Instantly share code, notes, and snippets.

@flying-sheep
Last active January 2, 2024 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flying-sheep/4ef2072763da268b1b1953e102ad21f1 to your computer and use it in GitHub Desktop.
Save flying-sheep/4ef2072763da268b1b1953e102ad21f1 to your computer and use it in GitHub Desktop.
/.*cache/
/__pycache__/
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)
[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"
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