Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat committed Aug 23, 2020
1 parent e90d3c5 commit 765fc89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/virtualenv/util/path/_pathlib/via_os_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ def read_bytes(self):
with open(self._path, "rb") as file_handler:
return file_handler.read()

def write_text(self, text, encoding="utf-8"):
self.write_bytes(text.encode(encoding))

def write_bytes(self, content):
with open(self._path, "wb") as file_handler:
file_handler.write(content)

def write_text(self, text, encoding="utf-8"):
self.write_bytes(text.encode(encoding))

def iterdir(self):
for p in os.listdir(self._path):
yield Path(os.path.join(self._path, p))
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/activation/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ def __call__(self, monkeypatch, tmp_path):
# check line endings are correct type
script_content = activate_script.read_bytes()
for line in script_content.split(b"\n")[:-1]:
cr = b'\r' if sys.version_info.major == 2 else 13
if self.unix_line_ending:
assert not line or line[-1] != 13, script_content.decode("utf-8")
assert line and line[-1] != cr, script_content.decode("utf-8")
else:
assert line[-1] == 13, script_content.decode("utf-8")
assert line[-1] == cr, script_content.decode("utf-8")

test_script = self._generate_test_script(activate_script, tmp_path)
monkeypatch.chdir(ensure_text(str(tmp_path)))
Expand Down

0 comments on commit 765fc89

Please sign in to comment.