Skip to content

Commit

Permalink
#2845 get coverge for new branch in SymbolTable
Browse files Browse the repository at this point in the history
  • Loading branch information
arporter committed Jan 15, 2025
1 parent f6b67f2 commit dbce296
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/psyclone/psyir/symbols/symbol_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,12 +1583,12 @@ def resolve_imports(self, container_symbols=None, symbol_target=None):
:type symbol_target: Optional[
:py:class:`psyclone.psyir.symbols.Symbol`]
:raises SymbolError: if a symbol name clash is found between multiple \
:raises SymbolError: if a symbol name clash is found between multiple
imports or an import and a local symbol.
:raises TypeError: if the provided container_symbols is not a list of \
:raises TypeError: if the provided container_symbols is not a list of
ContainerSymbols.
:raises TypeError: if the provided symbol_target is not a Symbol.
:raises KeyError: if a symbol_target has been specified but this has \
:raises KeyError: if a symbol_target has been specified but this has
not been found in any of the searched containers.
'''
Expand Down Expand Up @@ -1617,7 +1617,7 @@ def resolve_imports(self, container_symbols=None, symbol_target=None):
try:
external_container = c_symbol.find_container_psyir(
local_node=self.node)
# pylint: disable=broad-except
# pylint: disable-next=broad-except
except Exception:
# Ignore this container if the associated module file has not
# been found in the given include_path or any issue has arisen
Expand Down
14 changes: 14 additions & 0 deletions src/psyclone/tests/psyir/symbols/symbol_table_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,20 @@ def test_resolve_imports(fortran_reader, tmpdir, monkeypatch):
assert a_2.visibility == symbols.Symbol.Visibility.PRIVATE


def test_resolve_imports_missing_container(monkeypatch):
'''
Test that a clean failure to get Container PSyIR does not cause problems.
'''
table = symbols.SymbolTable()
csym = symbols.ContainerSymbol("a_mod")
# Monkeypatch the find_container_psyir() method of this ContainerSymbol
# so that it returns None.
monkeypatch.setattr(csym, "find_container_psyir", lambda local_node: None)
table.add(csym)
# Resolving imports should run without problems.
table.resolve_imports()


@pytest.mark.usefixtures("clear_module_manager_instance")
def test_resolve_imports_different_capitalization(
fortran_reader, tmpdir, monkeypatch):
Expand Down

0 comments on commit dbce296

Please sign in to comment.