Skip to content
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
13 changes: 13 additions & 0 deletions tests/unit/models/parsers/test_dependency_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def _local_imports(x):
return sqrt(a)


def _import_from_sibling(x, y):
from .test_for_parser import pair

a, b = pair(x, y)
return a, b


class TestGetCallDependencies(unittest.TestCase):
"""Tests for :func:`dependency_parser.get_call_dependencies`."""

Expand Down Expand Up @@ -185,6 +192,12 @@ def test_local_imports_included(self):
self.assertIn("sys.getsizeof", fqns)
self.assertIn("math.sqrt", fqns)

def test_relative_import_raises(self):
with self.assertRaises(ValueError) as ctx:
dependency_parser.get_call_dependencies(_import_from_sibling)
self.assertIn("Relative imports are not supported", str(ctx.exception))
self.assertIn("test_for_parser", str(ctx.exception))


class TestSplitByVersionAvailability(unittest.TestCase):
"""Tests for :func:`dependency_parser.split_by_version_availability`."""
Expand Down
Loading