diff --git a/cdd/__init__.py b/cdd/__init__.py index e39fb97d..45e7359b 100644 --- a/cdd/__init__.py +++ b/cdd/__init__.py @@ -8,7 +8,7 @@ from logging import getLogger as get_logger __author__ = "Samuel Marks" -__version__ = "0.0.99rc13" +__version__ = "0.0.99rc14" __description__ = ( "Open API to/fro routes, models, and tests. " "Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy." diff --git a/cdd/shared/parse/utils/parser_utils.py b/cdd/shared/parse/utils/parser_utils.py index 03f1f9d9..2c76dc84 100644 --- a/cdd/shared/parse/utils/parser_utils.py +++ b/cdd/shared/parse/utils/parser_utils.py @@ -193,7 +193,7 @@ def infer(*args, **kwargs): and not node.startswith("class ") ): return "docstring" - assert is_supported_ast_node + if isinstance(node, FunctionDef): if next( filter( diff --git a/cdd/tests/test_compound/test_exmod_utils.py b/cdd/tests/test_compound/test_exmod_utils.py index a99020d4..9107970b 100644 --- a/cdd/tests/test_compound/test_exmod_utils.py +++ b/cdd/tests/test_compound/test_exmod_utils.py @@ -8,7 +8,11 @@ from unittest import TestCase from unittest.mock import MagicMock, patch -from cdd.compound.exmod_utils import _emit_symbol, emit_file_on_hierarchy +from cdd.compound.exmod_utils import ( + _emit_symbol, + emit_file_on_hierarchy, + get_module_contents, +) from cdd.shared.pure_utils import INIT_FILENAME, quote, rpartial from cdd.tests.utils_for_tests import unittest_main @@ -87,5 +91,9 @@ def test__emit_symbols_isfile_emit_filename_true(self) -> None: f.assert_called_once() g.assert_called_once() + def test_get_module_contents_empty(self) -> None: + """`get_module_contents`""" + self.assertDictEqual(get_module_contents(None, "nonexistent", {}), {}) + unittest_main() diff --git a/cdd/tests/test_parse/test_parser_utils.py b/cdd/tests/test_parse/test_parser_utils.py index bc3368c5..17532149 100644 --- a/cdd/tests/test_parse/test_parser_utils.py +++ b/cdd/tests/test_parse/test_parser_utils.py @@ -245,6 +245,11 @@ def test_infer_memory_sqlalchemy(self) -> None: cdd.shared.parse.utils.parser_utils.infer(Config), "sqlalchemy" ) + def test_infer_raise(self) -> None: + """Test `infer` raises `NotImplementedError`""" + with self.assertRaises(NotImplementedError): + cdd.shared.parse.utils.parser_utils.infer(None) + def test_get_source_raises(self) -> None: """Tests that `get_source` raises an exception""" with self.assertRaises(TypeError): diff --git a/cdd/tests/test_shared/test_pure_utils.py b/cdd/tests/test_shared/test_pure_utils.py index c4201a52..c46fe5a1 100644 --- a/cdd/tests/test_shared/test_pure_utils.py +++ b/cdd/tests/test_shared/test_pure_utils.py @@ -5,6 +5,7 @@ from itertools import zip_longest from json import dumps from unittest import TestCase +from unittest.mock import patch from cdd.shared.pure_utils import ( SetEncoder, @@ -94,6 +95,14 @@ def test_find_module_filepath(self) -> None: "cdd.nosuchmodulecdd.tests", "test_pure_utils" ), ) + with patch("cdd.shared.pure_utils.find_spec", lambda _: None): + self.assertIsNone( + find_module_filepath( + "cdd.nosuchmodulecdd.tests", + "test_pure_utils", + none_when_no_spec=True, + ), + ) def test_pp(self) -> None: """Test that pp is from the right module"""