Skip to content

Commit 67ddad5

Browse files
committed
[cdd/compound/exmod_utils.py] Comment out unused function ; [cdd/tests/test_compound/test_exmod.py] test_exmod_single_folder_early_exit ; [cdd/__init__.py] Bump version ; [cdd/tests/test_shared/test_pkg_utils.py] test_get_python_lib add debug for windows
1 parent 6439bfc commit 67ddad5

File tree

4 files changed

+76
-39
lines changed

4 files changed

+76
-39
lines changed

cdd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from logging import getLogger as get_logger
1010

1111
__author__ = "Samuel Marks" # type: str
12-
__version__ = "0.0.99rc42" # type: str
12+
__version__ = "0.0.99rc43" # type: str
1313
__description__ = (
1414
"Open API to/fro routes, models, and tests. "
1515
"Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy."

cdd/compound/exmod_utils.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ast import walk as ast_walk
66
from collections import OrderedDict, defaultdict, deque
77
from functools import partial
8-
from inspect import getfile, ismodule
8+
from inspect import getfile
99
from itertools import chain
1010
from operator import attrgetter, eq
1111
from os import environ, extsep, makedirs, path
@@ -156,40 +156,40 @@ def get_module_contents(obj, module_root_dir, current_module=None, _result={}):
156156
return _result
157157

158158

159-
def _process_module_contents(_result, current_module, module_root_dir, name, symbol):
160-
"""
161-
Internal function to get the symbol and store it with a fully-qualified name in `_result`
162-
163-
:param current_module: The current module
164-
:type current_module: ```Optional[str]```
165-
166-
:param module_root_dir: Root of module
167-
:type module_root_dir: ```str```
168-
169-
:param name: Name—first value—from `dir(module)`
170-
:type name: ```str```
171-
172-
:param symbol: Symbol—second value—from `dir(module)`
173-
:type symbol: ```type```
174-
"""
175-
fq: str = "{current_module}.{name}".format(current_module=current_module, name=name)
176-
try:
177-
symbol_location: Optional[str] = getfile(symbol)
178-
except TypeError:
179-
symbol_location: Optional[str] = None
180-
if symbol_location is not None and symbol_location.startswith(module_root_dir):
181-
if isinstance(symbol, type):
182-
_result[fq] = symbol
183-
elif (
184-
current_module != getattr(symbol, "__name__", current_module)
185-
and ismodule(symbol)
186-
and fq not in _result
187-
):
188-
get_module_contents(
189-
symbol,
190-
module_root_dir=module_root_dir,
191-
current_module=symbol.__name__,
192-
)
159+
# def _process_module_contents(_result, current_module, module_root_dir, name, symbol):
160+
# """
161+
# Internal function to get the symbol and store it with a fully-qualified name in `_result`
162+
#
163+
# :param current_module: The current module
164+
# :type current_module: ```Optional[str]```
165+
#
166+
# :param module_root_dir: Root of module
167+
# :type module_root_dir: ```str```
168+
#
169+
# :param name: Name—first value—from `dir(module)`
170+
# :type name: ```str```
171+
#
172+
# :param symbol: Symbol—second value—from `dir(module)`
173+
# :type symbol: ```type```
174+
# """
175+
# fq: str = "{current_module}.{name}".format(current_module=current_module, name=name)
176+
# try:
177+
# symbol_location: Optional[str] = getfile(symbol)
178+
# except TypeError:
179+
# symbol_location: Optional[str] = None
180+
# if symbol_location is not None and symbol_location.startswith(module_root_dir):
181+
# if isinstance(symbol, type):
182+
# _result[fq] = symbol
183+
# elif (
184+
# current_module != getattr(symbol, "__name__", current_module)
185+
# and ismodule(symbol)
186+
# and fq not in _result
187+
# ):
188+
# get_module_contents(
189+
# symbol,
190+
# module_root_dir=module_root_dir,
191+
# current_module=symbol.__name__,
192+
# )
193193

194194

195195
def emit_file_on_hierarchy(

cdd/tests/test_compound/test_exmod.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from unittest.mock import patch
1616

1717
import cdd.class_.parse
18-
from cdd.compound.exmod import exmod
18+
from cdd.compound.exmod import exmod, exmod_single_folder
1919
from cdd.shared.ast_utils import maybe_type_comment, set_value
2020
from cdd.shared.pkg_utils import relative_filename
2121
from cdd.shared.pure_utils import (
@@ -429,6 +429,30 @@ def test_exmod_dry_run(self) -> None:
429429
finally:
430430
self._pip(["uninstall", "-y", self.package_root_name])
431431

432+
def test_exmod_single_folder_early_exit(self):
433+
"""
434+
Tests that `exmod_single_folder` exits early
435+
"""
436+
self.assertIsNone(
437+
exmod_single_folder(
438+
emit_name="sqlalchemy",
439+
module="mod",
440+
blacklist=["tmp.mod"],
441+
whitelist=[],
442+
output_directory="tmp",
443+
first_output_directory="tmp",
444+
mock_imports=True,
445+
no_word_wrap=True,
446+
dry_run=False,
447+
module_root_dir="tmp",
448+
module_root="tmp",
449+
module_name="mod",
450+
new_module_name="mod_new",
451+
filesystem_layout="as_input",
452+
extra_modules_to_all=None,
453+
)
454+
)
455+
432456
def create_and_install_pkg(self, root):
433457
"""
434458
Create and install the pacakge

cdd/tests/test_shared/test_pkg_utils.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
""" Tests for pkg utils """
22

3-
from functools import partial
43
from operator import eq
54
from os import path
65
from site import getsitepackages
76
from unittest import TestCase
87

98
from cdd.shared.pkg_utils import get_python_lib, relative_filename
10-
from cdd.shared.pure_utils import rpartial
9+
from cdd.shared.pure_utils import rpartial, pp
1110
from cdd.tests.utils_for_tests import unittest_main
1211

1312

@@ -23,6 +22,20 @@ def test_get_python_lib(self) -> None:
2322
"""Tests that `get_python_lib` works"""
2423
python_lib: str = get_python_lib()
2524
site_packages: str = getsitepackages()[0]
25+
two_dirs_above: str = path.dirname(path.dirname(site_packages))
26+
pp(
27+
{
28+
"python_lib": python_lib,
29+
"two_dirs_above": two_dirs_above,
30+
"site_packages": site_packages,
31+
'path.join(two_dir_above, "Lib", "site-packages")': path.join(
32+
two_dirs_above, "Lib", "site-packages"
33+
),
34+
'path.join(two_dir_above, "python3", "dist-packages")': path.join(
35+
two_dirs_above, "python3", "dist-packages"
36+
),
37+
}
38+
)
2639
site_packages: str = next(
2740
filter(
2841
rpartial(eq, python_lib),

0 commit comments

Comments
 (0)