Skip to content

Commit 962fd8c

Browse files
adam-grant-hendryLee-W
authored andcommitted
test(bump_command): use / path separator
The Windows path separator is the backslash (i.e. `\\`). This causes problems when python reads files from the `Users` folder since `\\U` is the prefix for a Unicode string in python. Since `os.path` can properly parse forward slashes on all OS's, we substitute `\\` for `/` wherever `os.path` methods return backslashes.
1 parent fc15df2 commit 962fd8c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/commands/test_bump_command.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,10 @@ def test_bump_when_version_inconsistent_in_version_files(
302302
tmp_version_file = tmp_commitizen_project.join("__version__.py")
303303
tmp_version_file.write("100.999.10000")
304304
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
305+
tmp_version_file_string = str(tmp_version_file).replace("\\", "/")
305306
tmp_commitizen_cfg_file.write(
306307
f"{tmp_commitizen_cfg_file.read()}\n"
307-
f'version_files = ["{str(tmp_version_file)}"]'
308+
f'version_files = ["{tmp_version_file_string}"]'
308309
)
309310

310311
create_file_and_commit("feat: new file")
@@ -323,9 +324,10 @@ def test_bump_files_only(mocker, tmp_commitizen_project):
323324
tmp_version_file = tmp_commitizen_project.join("__version__.py")
324325
tmp_version_file.write("0.1.0")
325326
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
327+
tmp_version_file_string = str(tmp_version_file).replace("\\", "/")
326328
tmp_commitizen_cfg_file.write(
327329
f"{tmp_commitizen_cfg_file.read()}\n"
328-
f'version_files = ["{str(tmp_version_file)}"]'
330+
f'version_files = ["{tmp_version_file_string}"]'
329331
)
330332

331333
create_file_and_commit("feat: new user interface")
@@ -355,10 +357,11 @@ def test_bump_local_version(mocker, tmp_commitizen_project):
355357
tmp_version_file = tmp_commitizen_project.join("__version__.py")
356358
tmp_version_file.write("4.5.1+0.1.0")
357359
tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
360+
tmp_version_file_string = str(tmp_version_file).replace("\\", "/")
358361
tmp_commitizen_cfg_file.write(
359362
f"[tool.commitizen]\n"
360363
'version="4.5.1+0.1.0"\n'
361-
f'version_files = ["{str(tmp_version_file)}"]'
364+
f'version_files = ["{tmp_version_file_string}"]'
362365
)
363366

364367
create_file_and_commit("feat: new user interface")

0 commit comments

Comments
 (0)