File tree Expand file tree Collapse file tree
tests/unit/models/parsers Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
97104class 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
189202class TestSplitByVersionAvailability (unittest .TestCase ):
190203 """Tests for :func:`dependency_parser.split_by_version_availability`."""
You can’t perform that action at this time.
0 commit comments