From 5fac1d254aecd0c7841f87d621ba8110cb7447cb Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Fri, 26 Jan 2024 01:07:05 -0500 Subject: [PATCH] [cdd/tests/test_compound/test_exmod_utils.py] `test__emit_symbols_isfile_emit_filename_true` mock new function calls as they are not what this function tests --- cdd/compound/exmod.py | 1 + cdd/compound/exmod_utils.py | 1 + cdd/tests/test_compound/test_exmod_utils.py | 24 +++++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cdd/compound/exmod.py b/cdd/compound/exmod.py index 13bf39fb..a794aa0a 100644 --- a/cdd/compound/exmod.py +++ b/cdd/compound/exmod.py @@ -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 diff --git a/cdd/compound/exmod_utils.py b/cdd/compound/exmod_utils.py index 6d5f5577..8d6a0d30 100644 --- a/cdd/compound/exmod_utils.py +++ b/cdd/compound/exmod_utils.py @@ -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 diff --git a/cdd/tests/test_compound/test_exmod_utils.py b/cdd/tests/test_compound/test_exmod_utils.py index 17a3d822..cb613c87 100644 --- a/cdd/tests/test_compound/test_exmod_utils.py +++ b/cdd/tests/test_compound/test_exmod_utils.py @@ -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", @@ -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`"""