Skip to content

Commit

Permalink
Fixing posix <-> windows compatibility issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Oct 24, 2020
1 parent 80b5f90 commit 7d6b75b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
12 changes: 6 additions & 6 deletions repo_helper/cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

# stdlib
import datetime
import os.path
import pathlib
import posixpath
from typing import List, Optional

# 3rd party
Expand Down Expand Up @@ -170,11 +170,11 @@ def init_repo(repo_path: pathlib.Path, templates: jinja2.Environment) -> List[st
(repo_path / "requirements.txt").touch()

return [
os.path.join(templates.globals["import_name"], "__init__.py"),
os.path.join(templates.globals["tests_dir"], "__init__.py"),
os.path.join(templates.globals["docs_dir"], "api", f"{templates.globals['modname']}.rst"),
os.path.join(templates.globals["docs_dir"], "index.rst"),
os.path.join(templates.globals["tests_dir"], "requirements.txt"),
posixpath.join(templates.globals["import_name"], "__init__.py"),
posixpath.join(templates.globals["tests_dir"], "__init__.py"),
posixpath.join(templates.globals["docs_dir"], "api", f"{templates.globals['modname']}.rst"),
posixpath.join(templates.globals["docs_dir"], "index.rst"),
posixpath.join(templates.globals["tests_dir"], "requirements.txt"),
"requirements.txt",
"LICENSE",
"README.rst",
Expand Down
3 changes: 2 additions & 1 deletion repo_helper/files/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# stdlib
import os.path
import pathlib
import posixpath
import re
from typing import Any, List

Expand Down Expand Up @@ -600,6 +601,6 @@ def make_pre_commit(repo_path: pathlib.Path, templates: jinja2.Environment) -> L
pre_commit = templates.get_template("pre-commit-config.yaml")
pre_commit_file = PathPlus(repo_path / ".pre-commit-config.yaml")

pre_commit_file.write_clean(pre_commit.render())
pre_commit_file.write_clean(pre_commit.render(join_path=posixpath.join))

return [pre_commit_file.name]
2 changes: 1 addition & 1 deletion tests/test_cli/test_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_wizard(git_repo: GitRepo, file_regression):

stdout = result.stdout.splitlines()
assert stdout[0] == "This wizard 🧙‍will guide you through creating a 'repo_helper.yml' configuration file."
assert re.match(r"This will be created in '.*[\/]repo_helper\.yml'\.", stdout[1])
assert re.match(r"This will be created in '.*[\\/]repo_helper\.yml'\.", stdout[1])
assert stdout[2] == "Do you want to continue? [y/N]: y"
assert not stdout[3]
assert stdout[4] == "Woah! That file already exists. It will be overwritten if you continue!"
Expand Down
3 changes: 2 additions & 1 deletion tests/test_files/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import os

# 3rd party
import posixpath
from pytest_regressions.file_regression import FileRegressionFixture

# this package
Expand Down Expand Up @@ -110,7 +111,7 @@ def test_ensure_tests_requirements(tmp_pathplus, demo_environment):
(tmp_pathplus / "tests" / "requirements.txt").write_text('')

managed_files = ensure_tests_requirements(tmp_pathplus, demo_environment)
assert managed_files == [os.path.join("tests", "requirements.txt")]
assert managed_files == [posixpath.join("tests", "requirements.txt")]

assert (tmp_pathplus / managed_files[0]).read_text(
encoding="UTF-8"
Expand Down

0 comments on commit 7d6b75b

Please sign in to comment.