Skip to content

Commit

Permalink
Don't patch Config for all the tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbaynham committed Apr 22, 2020
1 parent c66ade3 commit 2c28724
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/unit/command/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ def test_path_replacement():
config_filename = "./config/file"

# Extract the "rel()" function from Config._save_paths
Config._map_dirs = MagicMock()
Config._save_paths(None, config_filename)
_, rel_func = Config._map_dirs.call_args[0]
PatchedConfig = Config
PatchedConfig._map_dirs = MagicMock()
PatchedConfig._save_paths(None, config_filename)
_, rel_func = PatchedConfig._map_dirs.call_args[0]

assert rel_func("cache") == "../cache"
assert rel_func("../cache") == "../../cache"
Expand All @@ -30,9 +31,10 @@ def test_path_replacement_windows():
config_filename = "./config/file"

# Extract the "rel()" function from Config._save_paths
Config._map_dirs = MagicMock()
Config._save_paths(None, config_filename)
_, rel_func = Config._map_dirs.call_args[0]
PatchedConfig = Config
PatchedConfig._map_dirs = MagicMock()
PatchedConfig._save_paths(None, config_filename)
_, rel_func = PatchedConfig._map_dirs.call_args[0]

assert rel_func("..\\cache") == "../../cache"
assert rel_func("c:\\path\\to\\cache") == "c:/path/to/cache"

0 comments on commit 2c28724

Please sign in to comment.