Skip to content

Commit

Permalink
Change to os_makedirs_mock to replace all / with \ after using
Browse files Browse the repository at this point in the history
    os.path.join to concatenate dirs together to ensure \ are used
Added mock for os.path.dirname to make sure dirnames all use \
This would be so much easier if I actually had a mac system to test on
  • Loading branch information
MosesofEgypt committed Jun 15, 2017
1 parent f2b70c2 commit 1d47918
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,24 @@ def os_path_isdir_mock(path):
def os_makedirs_mock(root_dir):
dirs = root_dir.replace('/', '\\').split('\\')
for i in range(len(dirs)):
existing_dirs.add(os.path.join(*dirs[: i + 1]))
existing_dirs.add(
os.path.join(*dirs[: i + 1]).replace('/', '\\'))

def shutil_rmtree_mock(path):
existing_files.remove(path.replace('/', '\\'))

def os_path_dirname_mock(path):
dirname = ""
path = path.replace('/', '\\')
for dir in path.split('\\')[: -1]:
dirname += "%s\\" % dir
return dirname[: -1]

with mock.patch('os.path.exists', os_path_exists_mock) as m1,\
mock.patch('os.path.isdir', os_path_isdir_mock) as m2,\
mock.patch('os.makedirs', os_makedirs_mock) as m3,\
mock.patch('shutil.rmtree', shutil_rmtree_mock) as m4:
mock.patch('os.path.dirname', os_path_dirname_mock) as m3,\
mock.patch('os.makedirs', os_makedirs_mock) as m4,\
mock.patch('shutil.rmtree', shutil_rmtree_mock) as m5:
branch._preclean_branch_directory(download_tracker)

self.assertNotIn("root\\test", existing_files)
Expand Down

0 comments on commit 1d47918

Please sign in to comment.