Skip to content

Commit

Permalink
[cdd/tests/test_compound/test_exmod_utils.py] `test__emit_symbols_isf…
Browse files Browse the repository at this point in the history
…ile_emit_filename_true` mock new function calls as they are not what this function tests
  • Loading branch information
SamuelMarks committed Jan 26, 2024
1 parent 83a7972 commit 5fac1d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions cdd/compound/exmod.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Not a dead module
"""

import typing
from ast import Assign, Expr, ImportFrom, List, Load, Module, Name, Store, alias, parse
from collections import deque
Expand Down
1 change: 1 addition & 0 deletions cdd/compound/exmod_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Exmod utils """

import sys
from ast import AST, Assign, Expr, ImportFrom, List, Load, Module, Name, Store, alias
from ast import walk as ast_walk
Expand Down
24 changes: 17 additions & 7 deletions cdd/tests/test_compound/test_exmod_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,21 @@ def test_emit_file_on_hierarchy(self) -> None:

def test__emit_symbols_isfile_emit_filename_true(self) -> None:
"""Test `_emit_symbol` when `isfile_emit_filename is True`"""
with patch(
"cdd.compound.exmod_utils.EXMOD_OUT_STREAM", new_callable=StringIO
), patch(
"cdd.shared.ast_utils.merge_modules", MagicMock()
) as func__merge_modules, patch(
"cdd.shared.ast_utils.merge_assignment_lists", MagicMock()
) as func__merge_assignment_lists:
with (
patch("cdd.compound.exmod_utils.EXMOD_OUT_STREAM", new_callable=StringIO),
patch(
"cdd.shared.ast_utils.merge_modules", MagicMock()
) as func__merge_modules,
patch(
"cdd.shared.ast_utils.merge_assignment_lists", MagicMock()
) as func__merge_assignment_lists,
patch(
"cdd.compound.exmod_utils.infer_imports", MagicMock()
) as func__infer_imports,
patch(
"cdd.compound.exmod_utils.deduplicate_sorted_imports", MagicMock()
) as func__deduplicate_sorted_imports,
):
_emit_symbol(
name_orig_ir=("", "", dict()),
emit_name="argparse",
Expand All @@ -98,6 +106,8 @@ def test__emit_symbols_isfile_emit_filename_true(self) -> None:
)
func__merge_modules.assert_called_once()
func__merge_assignment_lists.assert_called_once()
func__infer_imports.assert_called_once()
func__deduplicate_sorted_imports.assert_called_once()

def test_get_module_contents_empty(self) -> None:
"""`get_module_contents`"""
Expand Down

0 comments on commit 5fac1d2

Please sign in to comment.