Skip to content

Commit 5196442

Browse files
committed
Fix unit tests for python 3.5
1 parent 94c7ccc commit 5196442

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

tests/test_basic.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ def setup_clean_mkdocs_folder(mkdocs_yml_path, output_path):
8484
testproject_path = output_path / "testproject"
8585

8686
# Create empty 'testproject' folder
87-
if os.path.exists(testproject_path):
87+
if os.path.exists(str(testproject_path)):
8888
logging.warning(
8989
"""This command does not work on windows.
9090
Refactor your test to use setup_clean_mkdocs_folder() only once"""
9191
)
92-
shutil.rmtree(testproject_path)
92+
shutil.rmtree(str(testproject_path))
9393

9494
# Copy correct mkdocs.yml file and our test 'docs/'
95-
shutil.copytree("tests/basic_setup/docs", testproject_path / "docs")
96-
shutil.copyfile(mkdocs_yml_path, testproject_path / "mkdocs.yml")
95+
shutil.copytree("tests/basic_setup/docs", str(testproject_path / "docs"))
96+
shutil.copyfile(mkdocs_yml_path, str(testproject_path / "mkdocs.yml"))
9797

9898
return testproject_path
9999

@@ -112,7 +112,8 @@ def setup_commit_history(testproject_path):
112112
Returns:
113113
repo (repo): git.Repo object
114114
"""
115-
assert not os.path.exists(testproject_path / ".git")
115+
assert not os.path.exists(str(testproject_path / ".git"))
116+
testproject_path = str(testproject_path)
116117

117118
repo = git.Repo.init(testproject_path, bare=False)
118119
author = "Test Person <testtest@gmail.com>"
@@ -164,7 +165,7 @@ def build_docs_setup(testproject_path):
164165

165166
# TODO: Try specifying path in CliRunner, this function could be one-liner
166167
cwd = os.getcwd()
167-
os.chdir(testproject_path)
168+
os.chdir(str(testproject_path))
168169

169170
try:
170171
runner = CliRunner()
@@ -183,21 +184,21 @@ def validate_build(testproject_path, plugin_config: dict):
183184
Args:
184185
testproject_path (Path): Path to test project
185186
"""
186-
assert os.path.exists(testproject_path / "site")
187+
assert os.path.exists(str(testproject_path / "site"))
187188

188189
# Make sure index file exists
189190
index_file = testproject_path / "site/index.html"
190-
assert index_file.exists(), f"{index_file} does not exist"
191+
assert index_file.exists(), "%s does not exist" % index_file
191192

192193
# Make sure with markdown tag has valid
193194
# git revision date tag
194195
page_with_tag = testproject_path / "site/page_with_tag/index.html"
195196
contents = page_with_tag.read_text(encoding="utf8")
196197
assert re.search(r"Markdown tag\:\s[<span>|\w].+", contents)
197198

198-
repo = Util(testproject_path)
199+
repo = Util(str(testproject_path))
199200
date_formats = repo.get_revision_date_for_file(
200-
path=testproject_path / "docs/page_with_tag.md",
201+
path=str(testproject_path / "docs/page_with_tag.md"),
201202
locale=plugin_config.get("locale"),
202203
fallback_to_build_date=plugin_config.get("fallback_to_build_date"),
203204
)
@@ -333,14 +334,14 @@ def test_low_fetch_depth(tmp_path, caplog):
333334
repo = setup_commit_history(testproject_path)
334335

335336
# Create a second, clean folder to clone to
336-
cloned_folder = tmp_path.parent / "clonedrepo"
337+
cloned_folder = str(tmp_path.parent / "clonedrepo")
337338
if os.path.exists(cloned_folder):
338339
shutil.rmtree(cloned_folder)
339-
os.mkdir(cloned_folder)
340+
# os.mkdir(cloned_folder)
340341

341342
# Clone the local repo with fetch depth of 1
342343
repo = git.Repo.init(cloned_folder, bare=False)
343-
origin = repo.create_remote("origin", testproject_path)
344+
origin = repo.create_remote("origin", str(testproject_path))
344345
origin.fetch(depth=1, prune=True)
345346
repo.create_head(
346347
"master", origin.refs.master

0 commit comments

Comments
 (0)