Skip to content

Commit

Permalink
Merge pull request #1336 from funilrys/issue-1332
Browse files Browse the repository at this point in the history
Fix directory separator under Windows.
  • Loading branch information
StevenBlack committed Jul 13, 2020
2 parents 82791b3 + abf763e commit 323174e
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions testUpdateHostsFile.py
Expand Up @@ -8,6 +8,7 @@
import json
import locale
import os
import platform
import re
import shutil
import sys
Expand Down Expand Up @@ -62,6 +63,8 @@ def mock_property(name):

@property
def sep(self):
if platform.system().lower() == "windows":
return "\\"
return os.sep

def assert_called_once(self, mock_method):
Expand Down Expand Up @@ -1122,12 +1125,13 @@ def test_add_fields(self):
)
update_readme_data(self.readme_file, **kwargs)

if platform.system().lower() == "windows":
sep = "/"
else:
sep = self.sep

expected = {
"base": {
"location": "foo" + self.sep,
"sourcesdata": "hosts",
"entries": 5,
},
"base": {"location": "foo" + sep, "sourcesdata": "hosts", "entries": 5},
"foo": "bar",
}

Expand All @@ -1144,8 +1148,13 @@ def test_modify_fields(self):
)
update_readme_data(self.readme_file, **kwargs)

if platform.system().lower() == "windows":
sep = "/"
else:
sep = self.sep

expected = {
"base": {"location": "foo" + self.sep, "sourcesdata": "hosts", "entries": 5}
"base": {"location": "foo" + sep, "sourcesdata": "hosts", "entries": 5}
}

with open(self.readme_file, "r") as f:
Expand All @@ -1164,12 +1173,13 @@ def test_set_extensions(self):
)
update_readme_data(self.readme_file, **kwargs)

if platform.system().lower() == "windows":
sep = "/"
else:
sep = self.sep

expected = {
"com-org": {
"location": "foo" + self.sep,
"sourcesdata": "hosts",
"entries": 5,
}
"com-org": {"location": "foo" + sep, "sourcesdata": "hosts", "entries": 5}
}

with open(self.readme_file, "r") as f:
Expand Down

0 comments on commit 323174e

Please sign in to comment.