Skip to content

Commit e6ff509

Browse files
committed
fixup: coverage, more ci
1 parent e3776eb commit e6ff509

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-22.04, windows-latest, macos-latest]
18-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
17+
os: [ubuntu-latest, windows-latest, macos-latest]
18+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
19+
include:
20+
- os: ubuntu-22.04
21+
python-version: "3.7"
22+
- os: windows-latest
23+
python-version: "3.7"
24+
- os: ubuntu-22.04
25+
python-version: "3.7"
1926
steps:
2027
- name: "Check out repository"
2128
uses: actions/checkout@v4

tests/fixtures.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def optional_child(self) -> Optional[SomeClass]:
5858
"""Get the child instance."""
5959
raise NotImplementedError()
6060

61+
@property
62+
def union_none_child(self) -> Union[None, SomeClass]:
63+
"""Get the child instance."""
64+
raise NotImplementedError()
65+
6166
@property
6267
def union_child(self) -> Union[SomeClass, "SomeAsyncClass"]:
6368
"""Get the child instance."""

tests/test_spy_core.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,12 @@ def test_warn_if_spec_does_not_have_method() -> None:
470470
parent = nested_class_subject.create_child_core("optional_child", False)
471471
parent.create_child_core("primitive_property", False)
472472

473+
# property access should be allowed through None unions
474+
with warnings.catch_warnings():
475+
warnings.simplefilter("error")
476+
parent = nested_class_subject.create_child_core("union_none_child", False)
477+
parent.create_child_core("primitive_property", False)
478+
473479
# property access should not be checked through unions
474480
with warnings.catch_warnings():
475481
warnings.simplefilter("error")
@@ -494,3 +500,10 @@ def test_warn_if_spec_does_not_have_method() -> None:
494500
):
495501
parent = nested_class_subject.create_child_core("optional_child", False)
496502
parent.create_child_core("this_is_wrong", False)
503+
504+
# incorrect nested property usage should warn
505+
with pytest.warns(
506+
MissingSpecAttributeWarning, match="has no attribute 'this_is_wrong'"
507+
):
508+
parent = nested_class_subject.create_child_core("union_none_child", False)
509+
parent.create_child_core("this_is_wrong", False)

0 commit comments

Comments
 (0)