Skip to content

Commit f4c2bc9

Browse files
authored
Merge pull request #191 from pyiron/import_parser-test
Test exception branch
2 parents 0312459 + b16ffab commit f4c2bc9

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/unit/models/parsers/test_dependency_parser.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ def _local_imports(x):
9494
return sqrt(a)
9595

9696

97+
def _import_from_sibling(x, y):
98+
from .test_for_parser import pair
99+
100+
a, b = pair(x, y)
101+
return a, b
102+
103+
97104
class TestGetCallDependencies(unittest.TestCase):
98105
"""Tests for :func:`dependency_parser.get_call_dependencies`."""
99106

@@ -185,6 +192,12 @@ def test_local_imports_included(self):
185192
self.assertIn("sys.getsizeof", fqns)
186193
self.assertIn("math.sqrt", fqns)
187194

195+
def test_relative_import_raises(self):
196+
with self.assertRaises(ValueError) as ctx:
197+
dependency_parser.get_call_dependencies(_import_from_sibling)
198+
self.assertIn("Relative imports are not supported", str(ctx.exception))
199+
self.assertIn("test_for_parser", str(ctx.exception))
200+
188201

189202
class TestSplitByVersionAvailability(unittest.TestCase):
190203
"""Tests for :func:`dependency_parser.split_by_version_availability`."""

0 commit comments

Comments
 (0)