Skip to content

Commit

Permalink
test: make tests cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
mbdevpl committed Aug 14, 2023
1 parent 1663cc9 commit c769c7a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@ class UnitTests(unittest.TestCase):
"""Test basic functionalities of the config boilerplate."""

def test_normalize_path(self):
home_path = os.environ['HOME']
home_path = os.path.expanduser('~')
self.assertEqual(boilerplates.config.normalize_path('~/folder'), f'{home_path}/folder')

self.assertEqual(
boilerplates.config.normalize_path(pathlib.Path('~', 'something')),
pathlib.Path(home_path).joinpath('something'))

envvar_value = 'my_custom_value'
os.environ['MY_CUSTOM_VAR'] = envvar_value

self.assertEqual(
boilerplates.config.normalize_path(r'${MY_CUSTOM_VAR}/folder'),
f'{envvar_value}/folder')

self.assertEqual(
boilerplates.config.normalize_path(pathlib.Path(r'${MY_CUSTOM_VAR}', 'something')),
pathlib.Path(envvar_value).joinpath('something'))

def test_initialize_config_directory(self):
with tempfile.TemporaryDirectory() as temp_dir:
with unittest.mock.patch.object(
Expand Down

0 comments on commit c769c7a

Please sign in to comment.