Skip to content

Commit 23cfeac

Browse files
committed
[cdd/tests/test_compound/test_exmod.py] Add tests for emit_sqlalchemy_submodule=True ; [cdd/sqlalchemy/utils/emit_utils.py] Fix keyword only arg issue with alias ; [cdd/tests/test_shared/test_pkg_utils.py] Work on test_get_python_lib ; [cdd/__init__.py] Bump version
1 parent 799d9a2 commit 23cfeac

File tree

4 files changed

+52
-14
lines changed

4 files changed

+52
-14
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.99rc38" # type: str
12+
__version__ = "0.0.99rc39" # type: str
1313
__description__ = (
1414
"Open API to/fro routes, models, and tests. "
1515
"Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy."

cdd/sqlalchemy/utils/emit_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,8 @@ def generate_create_tables_mod(module_name):
788788
module=module_name,
789789
names=list(
790790
map(
791-
partial(
792-
alias,
791+
lambda name: alias(
792+
name=name,
793793
asname=None,
794794
identifier=None,
795795
identifier_name=None,

cdd/tests/test_compound/test_exmod.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,45 @@ def test_exmod_output_directory_nonexistent(self) -> None:
258258
dry_run=False,
259259
)
260260

261+
def test_exmod_output__create_sqlalchemy_mod(self) -> None:
262+
"""
263+
Tests `exmod` module whence directory does not exist and that it:
264+
- calls `_create_sqlalchemy_mod`
265+
- that `_create_sqlalchemy_mod` works properly
266+
"""
267+
268+
try:
269+
with TemporaryDirectory(prefix="search_root", suffix="search_path") as root:
270+
existent_module_dir, new_module_dir = self.create_and_install_pkg(root)
271+
exmod(
272+
module=self.module_name,
273+
emit_name="sqlalchemy_table",
274+
blacklist=tuple(),
275+
whitelist=tuple(),
276+
mock_imports=True,
277+
emit_sqlalchemy_submodule=True,
278+
output_directory=new_module_dir,
279+
target_module_name="gold",
280+
extra_modules=None,
281+
no_word_wrap=None,
282+
recursive=False,
283+
dry_run=False,
284+
)
285+
# There are no conditionals in the generation, so just check existence
286+
sqlalchemy_mod_dir = path.join(new_module_dir, "sqlalchemy_mod")
287+
self.assertTrue(path.isdir(sqlalchemy_mod_dir))
288+
for name in ("__init__", "create_tables", "connection"):
289+
self.assertTrue(
290+
path.isfile(
291+
path.join(
292+
sqlalchemy_mod_dir, "{}{}py".format(name, path.extsep)
293+
)
294+
)
295+
)
296+
finally:
297+
# sys.path.remove(existent_module_dir)
298+
self._pip(["uninstall", "-y", self.package_root_name])
299+
261300
@skipIf(
262301
github_actions_and_non_windows_and_gte_3_12,
263302
github_actions_err,

cdd/tests/test_shared/test_pkg_utils.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@ def test_relative_filename(self) -> None:
1919

2020
def test_get_python_lib(self) -> None:
2121
"""Tests that `get_python_lib` works"""
22-
site_packages = getsitepackages()[0]
2322
python_lib = get_python_lib()
24-
if site_packages != python_lib:
23+
# Yes yes, I know; win32 note:
24+
site_packages = python_lib if platform == "win32" else getsitepackages()[0]
25+
if site_packages == python_lib:
26+
self.assertTrue(site_packages, python_lib)
27+
else:
2528
site_packages = path.dirname(path.dirname(site_packages))
26-
self.assertEqual(
27-
(
28-
python_lib # Yes yes, I know
29-
if platform == "win32"
30-
else (
29+
self.assertEqual(
30+
(
3131
site_packages
3232
if site_packages == python_lib
3333
else path.join(site_packages, "python3", "dist-packages")
34-
)
35-
),
36-
python_lib,
37-
)
34+
),
35+
python_lib,
36+
)
3837

3938

4039
unittest_main()

0 commit comments

Comments
 (0)