Skip to content

Commit

Permalink
[cdd/tests/test_{compound/test_exmod_utils,parse/test_parser_utils,sh…
Browse files Browse the repository at this point in the history
…ared/test_pure_utils}.py] Increase test coverage ; [cdd/__init__.py] Bump version so coverage badge gets updated]
  • Loading branch information
SamuelMarks committed Oct 2, 2023
1 parent 8817003 commit 01f8071
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cdd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion cdd/shared/parse/utils/parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 9 additions & 1 deletion cdd/tests/test_compound/test_exmod_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
5 changes: 5 additions & 0 deletions cdd/tests/test_parse/test_parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 9 additions & 0 deletions cdd/tests/test_shared/test_pure_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit 01f8071

Please sign in to comment.