Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken reference to pytest.Mark #367

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions tests/test_orm_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
)
from pyairtable.utils import datetime_to_iso_str

try:
from pytest import Mark as _PytestMark
except ImportError:
# older versions of pytest don't expose pytest.Mark directly
from _pytest.mark import Mark as _PytestMark


DATE_S = "2023-01-01"
DATE_V = datetime.date(2023, 1, 1)
DATETIME_S = "2023-04-12T09:30:00.000Z"
Expand Down Expand Up @@ -494,7 +501,7 @@ def assert_all_fields_tested_by(*test_fns, exclude=()):
"""

def extract_fields(obj):
if isinstance(obj, pytest.Mark):
if isinstance(obj, _PytestMark):
yield from [*extract_fields(obj.args), *extract_fields(obj.kwargs)]
elif isinstance(obj, str):
pass
Expand All @@ -511,7 +518,7 @@ def extract_fields(obj):
field_class
for test_function in test_fns
for pytestmark in getattr(test_function, "pytestmark", [])
if isinstance(pytestmark, pytest.Mark) and pytestmark.name == "parametrize"
if isinstance(pytestmark, _PytestMark) and pytestmark.name == "parametrize"
for field_class in extract_fields(pytestmark)
if field_class not in exclude
}
Expand Down
Loading