Skip to content

Commit

Permalink
[cdd/tests/test_compound/test_exmod.py] Fix tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelMarks committed Jul 3, 2023
1 parent 29dc471 commit 817666d
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions cdd/tests/test_compound/test_exmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,29 @@ def setUpClass(cls) -> None:
(cls.grandchild_name, cls.grandchild_dir),
)

@staticmethod
def normalise_double_paths(*dictionaries):
"""
On Windows the paths can come up weird, like C:\\\\foo instead of C:\\foo
This fixes that issue, and also safe to work on non-Windows
:param dictionaries: Dictionaries
:type dictionaries: ```Tuple[dictionaries]```
:return: `map` of normalised `dictionaries`
:rtype: ```map```
"""
return map(
lambda d: {
k: tuple(
map(repr, map(rpartial(str.replace, path.sep * 2, path.sep), v))
)
for k, v in d.items()
},
dictionaries,
)

def test_exmod(self) -> None:
"""Tests `exmod`"""

Expand Down Expand Up @@ -93,7 +116,10 @@ def test_exmod_blacklist(self) -> None:
dry_run=False,
)
self.assertListEqual(
listdir(new_module_dir), [INIT_FILENAME, self.parent_dir]
*map(
sorted,
(listdir(new_module_dir), [INIT_FILENAME, self.parent_dir]),
),
)
finally:
self._pip(["uninstall", "-y", self.package_root_name])
Expand Down Expand Up @@ -288,8 +314,7 @@ def test_exmod_dry_run(self) -> None:
}.items()
},
)
self.maxDiff = None
self.assertDictEqual(result, gold)
self.assertDictEqual(*self.normalise_double_paths(result, gold))

self._check_emission(new_module_dir, dry_run=True)
finally:
Expand Down Expand Up @@ -332,6 +357,7 @@ def create_and_install_pkg(self, root):
)
],
level=0,
identifier=None,
),
Assign(
targets=[Name("__author__", Store())],
Expand Down Expand Up @@ -444,6 +470,7 @@ def _create_fs(self, module_root):
)
],
level=0,
identifier=None,
)
for name, directory in self.module_hierarchy
),
Expand Down

0 comments on commit 817666d

Please sign in to comment.