Skip to content

Commit 89366bb

Browse files
author
Jeff Bloss
committed
Add Python version specification and refactor test for Node type hints exception handling
1 parent caa42d2 commit 89366bb

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

tests/test_dag_simple.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,19 +950,21 @@ class TestNodeEdgeCases:
950950

951951
def test_node_type_hints_exception(self) -> None:
952952
"""Test exception handling when getting type hints fails."""
953+
import sys
954+
from unittest.mock import patch
955+
956+
from dag_simple.node import Node
953957

954958
# Create a function with missing type hints to simulate problematic type hints
955959
def problematic_func(x: object) -> object:
956960
return x
957961

958-
from unittest.mock import patch
959-
960-
from dag_simple.node import Node
961-
962-
with patch("dag_simple.node.get_type_hints", side_effect=Exception("Type hint error")):
962+
# Patch get_type_hints where it's used in the node module
963+
# We need to patch the already-imported reference
964+
with patch.object(sys.modules["dag_simple.node"], "get_type_hints", side_effect=Exception("Type hint error")):
963965
# This should not raise an exception, but should disable validation
964-
node = Node(problematic_func, validate_types=True)
965-
assert node.validate_types is False
966+
node_instance = Node(problematic_func, validate_types=True)
967+
assert node_instance.validate_types is False
966968

967969
def test_node_repr(self) -> None:
968970
"""Test Node __repr__ method."""

0 commit comments

Comments
 (0)