Skip to content

Commit 7a004ea

Browse files
committed
[cdd/tests/test_shared/test_pkg_utils.py] Work on test_get_python_lib ; [cdd/__init__.py] Bump version
1 parent fb0c69c commit 7a004ea

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

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.99rc39" # type: str
12+
__version__ = "0.0.99rc40" # type: str
1313
__description__ = (
1414
"Open API to/fro routes, models, and tests. "
1515
"Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy."
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
""" Tests for pkg utils """
22

3+
from functools import partial
4+
from operator import eq
35
from os import path
46
from platform import platform
57
from site import getsitepackages
6-
from unittest import TestCase
8+
from unittest import TestCase, skipIf
79

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

22+
@skipIf(platform == "win32", "Skip hack for sitepackages check on Windows")
2023
def test_get_python_lib(self) -> None:
2124
"""Tests that `get_python_lib` works"""
22-
python_lib = get_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:
28-
site_packages = path.dirname(path.dirname(site_packages))
29-
self.assertEqual(
25+
python_lib: str = get_python_lib()
26+
site_packages: str = getsitepackages()[0]
27+
site_packages: str = next(
28+
filter(
29+
partial(eq, python_lib),
3030
(
31-
site_packages
32-
if site_packages == python_lib
33-
else path.join(site_packages, "python3", "dist-packages")
34-
),
35-
python_lib,
36-
)
31+
lambda two_dir_above: (
32+
site_packages,
33+
two_dir_above,
34+
path.join(two_dir_above, "python3", "dist-packages"),
35+
)
36+
)(path.dirname(path.dirname(site_packages))),
37+
),
38+
site_packages,
39+
)
40+
self.assertEqual(site_packages, python_lib)
3741

3842

3943
unittest_main()

0 commit comments

Comments
 (0)