Skip to content

Commit

Permalink
[cdd/tests/test_shared/test_pkg_utils.py] Work on `test_get_python_li…
Browse files Browse the repository at this point in the history
…b` ; [cdd/__init__.py] Bump version
  • Loading branch information
SamuelMarks committed Mar 15, 2024
1 parent 23cfeac commit 10c9b7b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cdd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from logging import getLogger as get_logger

__author__ = "Samuel Marks" # type: str
__version__ = "0.0.99rc39" # type: str
__version__ = "0.0.99rc40" # type: str
__description__ = (
"Open API to/fro routes, models, and tests. "
"Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy."
Expand Down
34 changes: 19 additions & 15 deletions cdd/tests/test_shared/test_pkg_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
""" Tests for pkg utils """

from functools import partial
from operator import eq
from os import path
from platform import platform
from site import getsitepackages
from unittest import TestCase
from unittest import TestCase, skipIf

from cdd.shared.pkg_utils import get_python_lib, relative_filename
from cdd.tests.utils_for_tests import unittest_main
Expand All @@ -17,23 +19,25 @@ def test_relative_filename(self) -> None:
expect: str = "gaffe"
self.assertEqual(relative_filename(expect), expect)

@skipIf(platform == "win32", "Skip hack for sitepackages check on Windows")
def test_get_python_lib(self) -> None:
"""Tests that `get_python_lib` works"""
python_lib = get_python_lib()
# Yes yes, I know; win32 note:
site_packages = python_lib if platform == "win32" else getsitepackages()[0]
if site_packages == python_lib:
self.assertTrue(site_packages, python_lib)
else:
site_packages = path.dirname(path.dirname(site_packages))
self.assertEqual(
python_lib: str = get_python_lib()
site_packages: str = getsitepackages()[0]
site_packages: str = next(
filter(
partial(eq, python_lib),
(
site_packages
if site_packages == python_lib
else path.join(site_packages, "python3", "dist-packages")
),
python_lib,
)
lambda two_dir_above: (
site_packages,
two_dir_above,
path.join(two_dir_above, "python3", "dist-packages"),
)
)(path.dirname(path.dirname(site_packages))),
),
site_packages,
)
self.assertEqual(site_packages, python_lib)


unittest_main()

0 comments on commit 10c9b7b

Please sign in to comment.