Skip to content

Commit 0e509dd

Browse files
authored
Merge pull request #488 from mxr/strpath
Don't use LocalPath.strpath
2 parents ebc15ad + f35bfed commit 0e509dd

23 files changed

+69
-69
lines changed

tests/check_added_large_files_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def has_gitlfs():
7575
@xfailif_no_gitlfs
7676
def test_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover
7777
with temp_git_dir.as_cwd():
78-
monkeypatch.setenv('HOME', str(temp_git_dir.strpath))
78+
monkeypatch.setenv('HOME', str(temp_git_dir))
7979
cmd_output('git', 'lfs', 'install')
8080
temp_git_dir.join('f.py').write('a' * 10000)
8181
cmd_output('git', 'lfs', 'track', 'f.py')
@@ -87,7 +87,7 @@ def test_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover
8787
@xfailif_no_gitlfs
8888
def test_moves_with_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover
8989
with temp_git_dir.as_cwd():
90-
monkeypatch.setenv('HOME', str(temp_git_dir.strpath))
90+
monkeypatch.setenv('HOME', str(temp_git_dir))
9191
cmd_output('git', 'lfs', 'install')
9292
cmd_output('git', 'lfs', 'track', 'a.bin', 'b.bin')
9393
# First add the file we're going to move

tests/check_builtin_literals_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ def test_ignore_constructors():
131131
def test_failing_file(tmpdir):
132132
f = tmpdir.join('f.py')
133133
f.write(BUILTIN_CONSTRUCTORS)
134-
rc = main([f.strpath])
134+
rc = main([str(f)])
135135
assert rc == 1
136136

137137

138138
def test_passing_file(tmpdir):
139139
f = tmpdir.join('f.py')
140140
f.write(BUILTIN_LITERALS)
141-
rc = main([f.strpath])
141+
rc = main([str(f)])
142142
assert rc == 0
143143

144144

145145
def test_failing_file_ignore_all(tmpdir):
146146
f = tmpdir.join('f.py')
147147
f.write(BUILTIN_CONSTRUCTORS)
148-
rc = main(['--ignore=complex,dict,float,int,list,str,tuple', f.strpath])
148+
rc = main(['--ignore=complex,dict,float,int,list,str,tuple', str(f)])
149149
assert rc == 0

tests/check_byte_order_marker_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
def test_failure(tmpdir):
55
f = tmpdir.join('f.txt')
66
f.write_text('ohai', encoding='utf-8-sig')
7-
assert check_byte_order_marker.main((f.strpath,)) == 1
7+
assert check_byte_order_marker.main((str(f),)) == 1
88

99

1010
def test_success(tmpdir):
1111
f = tmpdir.join('f.txt')
1212
f.write_text('ohai', encoding='utf-8')
13-
assert check_byte_order_marker.main((f.strpath,)) == 0
13+
assert check_byte_order_marker.main((str(f),)) == 0

tests/check_docstring_first_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def test_unit(capsys, contents, expected, expected_out):
5656
def test_integration(tmpdir, capsys, contents, expected, expected_out):
5757
f = tmpdir.join('test.py')
5858
f.write_binary(contents)
59-
assert main([f.strpath]) == expected
60-
assert capsys.readouterr()[0] == expected_out.format(filename=f.strpath)
59+
assert main([str(f)]) == expected
60+
assert capsys.readouterr()[0] == expected_out.format(filename=str(f))
6161

6262

6363
def test_arbitrary_encoding(tmpdir):
6464
f = tmpdir.join('f.py')
6565
contents = '# -*- coding: cp1252\nx = "£"'.encode('cp1252')
6666
f.write_binary(contents)
67-
assert main([f.strpath]) == 0
67+
assert main([str(f)]) == 0

tests/check_executables_have_shebangs_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
def test_has_shebang(content, tmpdir):
2626
path = tmpdir.join('path')
2727
path.write(content, 'wb')
28-
assert main((path.strpath,)) == 0
28+
assert main((str(path),)) == 0
2929

3030

3131
@skip_win32 # pragma: win32 no cover
@@ -41,7 +41,7 @@ def test_has_shebang(content, tmpdir):
4141
def test_bad_shebang(content, tmpdir, capsys):
4242
path = tmpdir.join('path')
4343
path.write(content, 'wb')
44-
assert main((path.strpath,)) == 1
44+
assert main((str(path),)) == 1
4545
_, stderr = capsys.readouterr()
4646
assert stderr.startswith(f'{path}: marked executable but')
4747

tests/check_merge_conflict_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def f1_is_a_conflict_file(tmpdir):
1616
repo2 = tmpdir.join('repo2')
1717
repo2_f1 = repo2.join('f1')
1818

19-
cmd_output('git', 'init', '--', repo1.strpath)
19+
cmd_output('git', 'init', '--', str(repo1))
2020
with repo1.as_cwd():
2121
repo1_f1.ensure()
2222
cmd_output('git', 'add', '.')
2323
cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1')
2424

25-
cmd_output('git', 'clone', repo1.strpath, repo2.strpath)
25+
cmd_output('git', 'clone', str(repo1), str(repo2))
2626

2727
# Commit in master
2828
with repo1.as_cwd():
@@ -71,13 +71,13 @@ def repository_pending_merge(tmpdir):
7171
repo2 = tmpdir.join('repo2')
7272
repo2_f1 = repo2.join('f1')
7373
repo2_f2 = repo2.join('f2')
74-
cmd_output('git', 'init', repo1.strpath)
74+
cmd_output('git', 'init', str(repo1))
7575
with repo1.as_cwd():
7676
repo1_f1.ensure()
7777
cmd_output('git', 'add', '.')
7878
cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1')
7979

80-
cmd_output('git', 'clone', repo1.strpath, repo2.strpath)
80+
cmd_output('git', 'clone', str(repo1), str(repo2))
8181

8282
# Commit in master
8383
with repo1.as_cwd():

tests/check_symlinks_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def test_main(tmpdir, dest, expected): # pragma: no cover (symlinks)
1616
tmpdir.join('exists').ensure()
1717
symlink = tmpdir.join('symlink')
1818
symlink.mksymlinkto(tmpdir.join(dest))
19-
assert main((symlink.strpath,)) == expected
19+
assert main((str(symlink),)) == expected
2020

2121

2222
def test_main_normal_file(tmpdir):
23-
assert main((tmpdir.join('f').ensure().strpath,)) == 0
23+
assert main((str(tmpdir.join('f').ensure()),)) == 0

tests/check_toml_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_toml_bad(tmpdir):
88
99
= "no key name" # INVALID
1010
""")
11-
ret = main((filename.strpath,))
11+
ret = main((str(filename),))
1212
assert ret == 1
1313

1414

@@ -25,12 +25,12 @@ def test_toml_good(tmpdir):
2525
dob = 1979-05-27T07:32:00-08:00 # First class dates
2626
""",
2727
)
28-
ret = main((filename.strpath,))
28+
ret = main((str(filename),))
2929
assert ret == 0
3030

3131

3232
def test_toml_good_unicode(tmpdir):
3333
filename = tmpdir.join('f')
3434
filename.write_binary('letter = "\N{SNOWMAN}"\n'.encode())
35-
ret = main((filename.strpath,))
35+
ret = main((str(filename),))
3636
assert ret == 0

tests/check_vcs_permalinks_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def test_trivial(tmpdir):
55
f = tmpdir.join('f.txt').ensure()
6-
assert not main((f.strpath,))
6+
assert not main((str(f),))
77

88

99
def test_passing(tmpdir):
@@ -16,7 +16,7 @@ def test_passing(tmpdir):
1616
# regression test for overly-greedy regex
1717
b'https://github.com/ yes / no ? /blob/master/foo#L1\n',
1818
)
19-
assert not main((f.strpath,))
19+
assert not main((str(f),))
2020

2121

2222
def test_failing(tmpdir, capsys):

tests/check_yaml_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ def test_main_allow_multiple_documents(tmpdir):
2020
f.write('---\nfoo\n---\nbar\n')
2121

2222
# should fail without the setting
23-
assert main((f.strpath,))
23+
assert main((str(f),))
2424

2525
# should pass when we allow multiple documents
26-
assert not main(('--allow-multiple-documents', f.strpath))
26+
assert not main(('--allow-multiple-documents', str(f)))
2727

2828

2929
def test_fails_even_with_allow_multiple_documents(tmpdir):
3030
f = tmpdir.join('test.yaml')
3131
f.write('[')
32-
assert main(('--allow-multiple-documents', f.strpath))
32+
assert main(('--allow-multiple-documents', str(f)))
3333

3434

3535
def test_main_unsafe(tmpdir):
@@ -40,12 +40,12 @@ def test_main_unsafe(tmpdir):
4040
' deadbeefdeadbeefdeadbeef\n',
4141
)
4242
# should fail "safe" check
43-
assert main((f.strpath,))
43+
assert main((str(f),))
4444
# should pass when we allow unsafe documents
45-
assert not main(('--unsafe', f.strpath))
45+
assert not main(('--unsafe', str(f)))
4646

4747

4848
def test_main_unsafe_still_fails_on_syntax_errors(tmpdir):
4949
f = tmpdir.join('test.yaml')
5050
f.write('[')
51-
assert main(('--unsafe', f.strpath))
51+
assert main(('--unsafe', str(f)))

0 commit comments

Comments
 (0)