diff --git a/tests/check_added_large_files_test.py b/tests/check_added_large_files_test.py index c33a9ca..40ffd24 100644 --- a/tests/check_added_large_files_test.py +++ b/tests/check_added_large_files_test.py @@ -75,7 +75,7 @@ xfailif_no_gitlfs = pytest.mark.xfail( @xfailif_no_gitlfs def test_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover with temp_git_dir.as_cwd(): - monkeypatch.setenv('HOME', str(temp_git_dir.strpath)) + monkeypatch.setenv('HOME', str(temp_git_dir)) cmd_output('git', 'lfs', 'install') temp_git_dir.join('f.py').write('a' * 10000) cmd_output('git', 'lfs', 'track', 'f.py') @@ -87,7 +87,7 @@ def test_allows_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover @xfailif_no_gitlfs def test_moves_with_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover with temp_git_dir.as_cwd(): - monkeypatch.setenv('HOME', str(temp_git_dir.strpath)) + monkeypatch.setenv('HOME', str(temp_git_dir)) cmd_output('git', 'lfs', 'install') cmd_output('git', 'lfs', 'track', 'a.bin', 'b.bin') # First add the file we're going to move diff --git a/tests/check_builtin_literals_test.py b/tests/check_builtin_literals_test.py index 01193e8..e936798 100644 --- a/tests/check_builtin_literals_test.py +++ b/tests/check_builtin_literals_test.py @@ -131,19 +131,19 @@ def test_ignore_constructors(): def test_failing_file(tmpdir): f = tmpdir.join('f.py') f.write(BUILTIN_CONSTRUCTORS) - rc = main([f.strpath]) + rc = main([str(f)]) assert rc == 1 def test_passing_file(tmpdir): f = tmpdir.join('f.py') f.write(BUILTIN_LITERALS) - rc = main([f.strpath]) + rc = main([str(f)]) assert rc == 0 def test_failing_file_ignore_all(tmpdir): f = tmpdir.join('f.py') f.write(BUILTIN_CONSTRUCTORS) - rc = main(['--ignore=complex,dict,float,int,list,str,tuple', f.strpath]) + rc = main(['--ignore=complex,dict,float,int,list,str,tuple', str(f)]) assert rc == 0 diff --git a/tests/check_byte_order_marker_test.py b/tests/check_byte_order_marker_test.py index 9995200..4c40247 100644 --- a/tests/check_byte_order_marker_test.py +++ b/tests/check_byte_order_marker_test.py @@ -4,10 +4,10 @@ from pre_commit_hooks import check_byte_order_marker def test_failure(tmpdir): f = tmpdir.join('f.txt') f.write_text('ohai', encoding='utf-8-sig') - assert check_byte_order_marker.main((f.strpath,)) == 1 + assert check_byte_order_marker.main((str(f),)) == 1 def test_success(tmpdir): f = tmpdir.join('f.txt') f.write_text('ohai', encoding='utf-8') - assert check_byte_order_marker.main((f.strpath,)) == 0 + assert check_byte_order_marker.main((str(f),)) == 0 diff --git a/tests/check_docstring_first_test.py b/tests/check_docstring_first_test.py index 7ad876f..ed5c08e 100644 --- a/tests/check_docstring_first_test.py +++ b/tests/check_docstring_first_test.py @@ -56,12 +56,12 @@ def test_unit(capsys, contents, expected, expected_out): def test_integration(tmpdir, capsys, contents, expected, expected_out): f = tmpdir.join('test.py') f.write_binary(contents) - assert main([f.strpath]) == expected - assert capsys.readouterr()[0] == expected_out.format(filename=f.strpath) + assert main([str(f)]) == expected + assert capsys.readouterr()[0] == expected_out.format(filename=str(f)) def test_arbitrary_encoding(tmpdir): f = tmpdir.join('f.py') contents = '# -*- coding: cp1252\nx = "£"'.encode('cp1252') f.write_binary(contents) - assert main([f.strpath]) == 0 + assert main([str(f)]) == 0 diff --git a/tests/check_executables_have_shebangs_test.py b/tests/check_executables_have_shebangs_test.py index 9c70334..5895a2a 100644 --- a/tests/check_executables_have_shebangs_test.py +++ b/tests/check_executables_have_shebangs_test.py @@ -25,7 +25,7 @@ skip_win32 = pytest.mark.skipif( def test_has_shebang(content, tmpdir): path = tmpdir.join('path') path.write(content, 'wb') - assert main((path.strpath,)) == 0 + assert main((str(path),)) == 0 @skip_win32 # pragma: win32 no cover @@ -41,7 +41,7 @@ def test_has_shebang(content, tmpdir): def test_bad_shebang(content, tmpdir, capsys): path = tmpdir.join('path') path.write(content, 'wb') - assert main((path.strpath,)) == 1 + assert main((str(path),)) == 1 _, stderr = capsys.readouterr() assert stderr.startswith(f'{path}: marked executable but') diff --git a/tests/check_merge_conflict_test.py b/tests/check_merge_conflict_test.py index 9968507..fccf41f 100644 --- a/tests/check_merge_conflict_test.py +++ b/tests/check_merge_conflict_test.py @@ -16,13 +16,13 @@ def f1_is_a_conflict_file(tmpdir): repo2 = tmpdir.join('repo2') repo2_f1 = repo2.join('f1') - cmd_output('git', 'init', '--', repo1.strpath) + cmd_output('git', 'init', '--', str(repo1)) with repo1.as_cwd(): repo1_f1.ensure() cmd_output('git', 'add', '.') cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1') - cmd_output('git', 'clone', repo1.strpath, repo2.strpath) + cmd_output('git', 'clone', str(repo1), str(repo2)) # Commit in master with repo1.as_cwd(): @@ -71,13 +71,13 @@ def repository_pending_merge(tmpdir): repo2 = tmpdir.join('repo2') repo2_f1 = repo2.join('f1') repo2_f2 = repo2.join('f2') - cmd_output('git', 'init', repo1.strpath) + cmd_output('git', 'init', str(repo1)) with repo1.as_cwd(): repo1_f1.ensure() cmd_output('git', 'add', '.') cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'commit1') - cmd_output('git', 'clone', repo1.strpath, repo2.strpath) + cmd_output('git', 'clone', str(repo1), str(repo2)) # Commit in master with repo1.as_cwd(): diff --git a/tests/check_symlinks_test.py b/tests/check_symlinks_test.py index ecbc7ae..07c1168 100644 --- a/tests/check_symlinks_test.py +++ b/tests/check_symlinks_test.py @@ -16,8 +16,8 @@ def test_main(tmpdir, dest, expected): # pragma: no cover (symlinks) tmpdir.join('exists').ensure() symlink = tmpdir.join('symlink') symlink.mksymlinkto(tmpdir.join(dest)) - assert main((symlink.strpath,)) == expected + assert main((str(symlink),)) == expected def test_main_normal_file(tmpdir): - assert main((tmpdir.join('f').ensure().strpath,)) == 0 + assert main((str(tmpdir.join('f').ensure()),)) == 0 diff --git a/tests/check_toml_test.py b/tests/check_toml_test.py index 3283717..c7251eb 100644 --- a/tests/check_toml_test.py +++ b/tests/check_toml_test.py @@ -8,7 +8,7 @@ key = # INVALID = "no key name" # INVALID """) - ret = main((filename.strpath,)) + ret = main((str(filename),)) assert ret == 1 @@ -25,12 +25,12 @@ name = "John" dob = 1979-05-27T07:32:00-08:00 # First class dates """, ) - ret = main((filename.strpath,)) + ret = main((str(filename),)) assert ret == 0 def test_toml_good_unicode(tmpdir): filename = tmpdir.join('f') filename.write_binary('letter = "\N{SNOWMAN}"\n'.encode()) - ret = main((filename.strpath,)) + ret = main((str(filename),)) assert ret == 0 diff --git a/tests/check_vcs_permalinks_test.py b/tests/check_vcs_permalinks_test.py index b893c98..19b1c35 100644 --- a/tests/check_vcs_permalinks_test.py +++ b/tests/check_vcs_permalinks_test.py @@ -3,7 +3,7 @@ from pre_commit_hooks.check_vcs_permalinks import main def test_trivial(tmpdir): f = tmpdir.join('f.txt').ensure() - assert not main((f.strpath,)) + assert not main((str(f),)) def test_passing(tmpdir): @@ -16,7 +16,7 @@ def test_passing(tmpdir): # regression test for overly-greedy regex b'https://github.com/ yes / no ? /blob/master/foo#L1\n', ) - assert not main((f.strpath,)) + assert not main((str(f),)) def test_failing(tmpdir, capsys): diff --git a/tests/check_yaml_test.py b/tests/check_yaml_test.py index 2f869d1..1a017a1 100644 --- a/tests/check_yaml_test.py +++ b/tests/check_yaml_test.py @@ -20,16 +20,16 @@ def test_main_allow_multiple_documents(tmpdir): f.write('---\nfoo\n---\nbar\n') # should fail without the setting - assert main((f.strpath,)) + assert main((str(f),)) # should pass when we allow multiple documents - assert not main(('--allow-multiple-documents', f.strpath)) + assert not main(('--allow-multiple-documents', str(f))) def test_fails_even_with_allow_multiple_documents(tmpdir): f = tmpdir.join('test.yaml') f.write('[') - assert main(('--allow-multiple-documents', f.strpath)) + assert main(('--allow-multiple-documents', str(f))) def test_main_unsafe(tmpdir): @@ -40,12 +40,12 @@ def test_main_unsafe(tmpdir): ' deadbeefdeadbeefdeadbeef\n', ) # should fail "safe" check - assert main((f.strpath,)) + assert main((str(f),)) # should pass when we allow unsafe documents - assert not main(('--unsafe', f.strpath)) + assert not main(('--unsafe', str(f))) def test_main_unsafe_still_fails_on_syntax_errors(tmpdir): f = tmpdir.join('test.yaml') f.write('[') - assert main(('--unsafe', f.strpath)) + assert main(('--unsafe', str(f))) diff --git a/tests/conftest.py b/tests/conftest.py index f98ae34..f92cfc1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,5 +6,5 @@ from pre_commit_hooks.util import cmd_output @pytest.fixture def temp_git_dir(tmpdir): git_dir = tmpdir.join('gits') - cmd_output('git', 'init', '--', git_dir.strpath) + cmd_output('git', 'init', '--', str(git_dir)) yield git_dir diff --git a/tests/debug_statement_hook_test.py b/tests/debug_statement_hook_test.py index f2cabc1..428421a 100644 --- a/tests/debug_statement_hook_test.py +++ b/tests/debug_statement_hook_test.py @@ -33,7 +33,7 @@ def test_finds_breakpoint(): def test_returns_one_for_failing_file(tmpdir): f_py = tmpdir.join('f.py') f_py.write('def f():\n import pdb; pdb.set_trace()') - ret = main([f_py.strpath]) + ret = main([str(f_py)]) assert ret == 1 @@ -50,10 +50,10 @@ def test_syntaxerror_file(): def test_non_utf8_file(tmpdir): f_py = tmpdir.join('f.py') f_py.write_binary('# -*- coding: cp1252 -*-\nx = "€"\n'.encode('cp1252')) - assert main((f_py.strpath,)) == 0 + assert main((str(f_py),)) == 0 def test_py37_breakpoint(tmpdir): f_py = tmpdir.join('f.py') f_py.write('def f():\n breakpoint()\n') - assert main((f_py.strpath,)) == 1 + assert main((str(f_py),)) == 1 diff --git a/tests/detect_private_key_test.py b/tests/detect_private_key_test.py index 9266f2b..7281000 100644 --- a/tests/detect_private_key_test.py +++ b/tests/detect_private_key_test.py @@ -21,4 +21,4 @@ TESTS = ( def test_main(input_s, expected_retval, tmpdir): path = tmpdir.join('file.txt') path.write_binary(input_s) - assert main([path.strpath]) == expected_retval + assert main([str(path)]) == expected_retval diff --git a/tests/end_of_file_fixer_test.py b/tests/end_of_file_fixer_test.py index 7f644e7..60b9e82 100644 --- a/tests/end_of_file_fixer_test.py +++ b/tests/end_of_file_fixer_test.py @@ -35,7 +35,7 @@ def test_integration(input_s, expected_retval, output, tmpdir): path = tmpdir.join('file.txt') path.write_binary(input_s) - ret = main([path.strpath]) + ret = main([str(path)]) file_output = path.read_binary() assert file_output == output diff --git a/tests/file_contents_sorter_test.py b/tests/file_contents_sorter_test.py index 1f9a14b..c8afc2d 100644 --- a/tests/file_contents_sorter_test.py +++ b/tests/file_contents_sorter_test.py @@ -27,7 +27,7 @@ def test_integration(input_s, expected_retval, output, tmpdir): path = tmpdir.join('file.txt') path.write_binary(input_s) - output_retval = main([path.strpath]) + output_retval = main([str(path)]) assert path.read_binary() == output assert output_retval == expected_retval diff --git a/tests/fix_encoding_pragma_test.py b/tests/fix_encoding_pragma_test.py index f3531f2..f3afa09 100644 --- a/tests/fix_encoding_pragma_test.py +++ b/tests/fix_encoding_pragma_test.py @@ -11,7 +11,7 @@ def test_integration_inserting_pragma(tmpdir): path = tmpdir.join('foo.py') path.write_binary(b'import httplib\n') - assert main((path.strpath,)) == 1 + assert main((str(path),)) == 1 assert path.read_binary() == ( b'# -*- coding: utf-8 -*-\n' @@ -22,14 +22,14 @@ def test_integration_inserting_pragma(tmpdir): def test_integration_ok(tmpdir): path = tmpdir.join('foo.py') path.write_binary(b'# -*- coding: utf-8 -*-\nx = 1\n') - assert main((path.strpath,)) == 0 + assert main((str(path),)) == 0 def test_integration_remove(tmpdir): path = tmpdir.join('foo.py') path.write_binary(b'# -*- coding: utf-8 -*-\nx = 1\n') - assert main((path.strpath, '--remove')) == 1 + assert main((str(path), '--remove')) == 1 assert path.read_binary() == b'x = 1\n' @@ -37,7 +37,7 @@ def test_integration_remove(tmpdir): def test_integration_remove_ok(tmpdir): path = tmpdir.join('foo.py') path.write_binary(b'x = 1\n') - assert main((path.strpath, '--remove')) == 0 + assert main((str(path), '--remove')) == 0 @pytest.mark.parametrize( @@ -140,20 +140,20 @@ def test_integration_alternate_pragma(tmpdir, capsys): f.write('x = 1\n') pragma = '# coding: utf-8' - assert main((f.strpath, '--pragma', pragma)) == 1 + assert main((str(f), '--pragma', pragma)) == 1 assert f.read() == '# coding: utf-8\nx = 1\n' out, _ = capsys.readouterr() - assert out == f'Added `# coding: utf-8` to {f.strpath}\n' + assert out == f'Added `# coding: utf-8` to {str(f)}\n' def test_crlf_ok(tmpdir): f = tmpdir.join('f.py') f.write_binary(b'# -*- coding: utf-8 -*-\r\nx = 1\r\n') - assert not main((f.strpath,)) + assert not main((str(f),)) def test_crfl_adds(tmpdir): f = tmpdir.join('f.py') f.write_binary(b'x = 1\r\n') - assert main((f.strpath,)) + assert main((str(f),)) assert f.read_binary() == b'# -*- coding: utf-8 -*-\r\nx = 1\r\n' diff --git a/tests/forbid_new_submodules_test.py b/tests/forbid_new_submodules_test.py index 7619182..4871ae7 100644 --- a/tests/forbid_new_submodules_test.py +++ b/tests/forbid_new_submodules_test.py @@ -15,7 +15,7 @@ def git_dir_with_git_dir(tmpdir): subprocess.check_call(('git', 'init', 'foo')) subprocess.check_call( ('git', 'commit', '-m', 'init', '--allow-empty', '--no-gpg-sign'), - cwd=tmpdir.join('foo').strpath, + cwd=str(tmpdir.join('foo')), ) yield diff --git a/tests/mixed_line_ending_test.py b/tests/mixed_line_ending_test.py index c438f74..f1c2641 100644 --- a/tests/mixed_line_ending_test.py +++ b/tests/mixed_line_ending_test.py @@ -25,7 +25,7 @@ from pre_commit_hooks.mixed_line_ending import main def test_mixed_line_ending_fixes_auto(input_s, output, tmpdir): path = tmpdir.join('file.txt') path.write_binary(input_s) - ret = main((path.strpath,)) + ret = main((str(path),)) assert ret == 1 assert path.read_binary() == output @@ -34,7 +34,7 @@ def test_mixed_line_ending_fixes_auto(input_s, output, tmpdir): def test_non_mixed_no_newline_end_of_file(tmpdir): path = tmpdir.join('f.txt') path.write_binary(b'foo\nbar\nbaz') - assert not main((path.strpath,)) + assert not main((str(path),)) # the hook *could* fix the end of the file, but leaves it alone # this is mostly to document the current behaviour assert path.read_binary() == b'foo\nbar\nbaz' @@ -43,7 +43,7 @@ def test_non_mixed_no_newline_end_of_file(tmpdir): def test_mixed_no_newline_end_of_file(tmpdir): path = tmpdir.join('f.txt') path.write_binary(b'foo\r\nbar\nbaz') - assert main((path.strpath,)) + assert main((str(path),)) # the hook rewrites the end of the file, this is slightly inconsistent # with the non-mixed case but I think this is the better behaviour # this is mostly to document the current behaviour @@ -66,7 +66,7 @@ def test_mixed_no_newline_end_of_file(tmpdir): def test_line_endings_ok(fix_option, input_s, tmpdir, capsys): path = tmpdir.join('input.txt') path.write_binary(input_s) - ret = main((fix_option, path.strpath)) + ret = main((fix_option, str(path))) assert ret == 0 assert path.read_binary() == input_s @@ -78,7 +78,7 @@ def test_no_fix_does_not_modify(tmpdir, capsys): path = tmpdir.join('input.txt') contents = b'foo\r\nbar\rbaz\nwomp\n' path.write_binary(contents) - ret = main(('--fix=no', path.strpath)) + ret = main(('--fix=no', str(path))) assert ret == 1 assert path.read_binary() == contents @@ -89,7 +89,7 @@ def test_no_fix_does_not_modify(tmpdir, capsys): def test_fix_lf(tmpdir, capsys): path = tmpdir.join('input.txt') path.write_binary(b'foo\r\nbar\rbaz\n') - ret = main(('--fix=lf', path.strpath)) + ret = main(('--fix=lf', str(path))) assert ret == 1 assert path.read_binary() == b'foo\nbar\nbaz\n' @@ -100,7 +100,7 @@ def test_fix_lf(tmpdir, capsys): def test_fix_crlf(tmpdir): path = tmpdir.join('input.txt') path.write_binary(b'foo\r\nbar\rbaz\n') - ret = main(('--fix=crlf', path.strpath)) + ret = main(('--fix=crlf', str(path))) assert ret == 1 assert path.read_binary() == b'foo\r\nbar\r\nbaz\r\n' @@ -110,7 +110,7 @@ def test_fix_lf_all_crlf(tmpdir): """Regression test for #239""" path = tmpdir.join('input.txt') path.write_binary(b'foo\r\nbar\r\n') - ret = main(('--fix=lf', path.strpath)) + ret = main(('--fix=lf', str(path))) assert ret == 1 assert path.read_binary() == b'foo\nbar\n' diff --git a/tests/pretty_format_json_test.py b/tests/pretty_format_json_test.py index 59a87f0..7fda23b 100644 --- a/tests/pretty_format_json_test.py +++ b/tests/pretty_format_json_test.py @@ -67,16 +67,16 @@ def test_autofix_main(tmpdir): srcfile = tmpdir.join('to_be_json_formatted.json') shutil.copyfile( get_resource_path('not_pretty_formatted_json.json'), - srcfile.strpath, + str(srcfile), ) # now launch the autofix on that file - ret = main(['--autofix', srcfile.strpath]) + ret = main(['--autofix', str(srcfile)]) # it should have formatted it assert ret == 1 # file was formatted (shouldn't trigger linter again) - ret = main([srcfile.strpath]) + ret = main([str(srcfile)]) assert ret == 0 diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index fae5a72..f4f679d 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -93,7 +93,7 @@ def test_integration(input_s, expected_retval, output, tmpdir): path = tmpdir.join('file.txt') path.write_binary(input_s) - output_retval = main([path.strpath]) + output_retval = main([str(path)]) assert path.read_binary() == output assert output_retval == expected_retval diff --git a/tests/sort_simple_yaml_test.py b/tests/sort_simple_yaml_test.py index 77e95d5..a682c15 100644 --- a/tests/sort_simple_yaml_test.py +++ b/tests/sort_simple_yaml_test.py @@ -39,7 +39,7 @@ TEST_SORTS = [ @pytest.mark.parametrize('bad_lines,good_lines,retval', TEST_SORTS) def test_integration_good_bad_lines(tmpdir, bad_lines, good_lines, retval): - file_path = os.path.join(tmpdir.strpath, 'foo.yaml') + file_path = os.path.join(str(tmpdir), 'foo.yaml') with open(file_path, 'w') as f: f.write('\n'.join(bad_lines) + '\n') diff --git a/tests/string_fixer_test.py b/tests/string_fixer_test.py index 77a51cf..6ddb0ac 100644 --- a/tests/string_fixer_test.py +++ b/tests/string_fixer_test.py @@ -42,7 +42,7 @@ TESTS = ( def test_rewrite(input_s, output, expected_retval, tmpdir): path = tmpdir.join('file.py') path.write(input_s) - retval = main([path.strpath]) + retval = main([str(path)]) assert path.read() == output assert retval == expected_retval @@ -50,5 +50,5 @@ def test_rewrite(input_s, output, expected_retval, tmpdir): def test_rewrite_crlf(tmpdir): f = tmpdir.join('f.py') f.write_binary(b'"foo"\r\n"bar"\r\n') - assert main((f.strpath,)) + assert main((str(f),)) assert f.read_binary() == b"'foo'\r\n'bar'\r\n" diff --git a/tests/trailing_whitespace_fixer_test.py b/tests/trailing_whitespace_fixer_test.py index 53177ac..bb3b62d 100644 --- a/tests/trailing_whitespace_fixer_test.py +++ b/tests/trailing_whitespace_fixer_test.py @@ -13,14 +13,14 @@ from pre_commit_hooks.trailing_whitespace_fixer import main def test_fixes_trailing_whitespace(input_s, expected, tmpdir): path = tmpdir.join('file.md') path.write(input_s) - assert main((path.strpath,)) == 1 + assert main((str(path),)) == 1 assert path.read() == expected def test_ok_no_newline_end_of_file(tmpdir): filename = tmpdir.join('f') filename.write_binary(b'foo\nbar') - ret = main((filename.strpath,)) + ret = main((str(filename),)) assert filename.read_binary() == b'foo\nbar' assert ret == 0 @@ -28,7 +28,7 @@ def test_ok_no_newline_end_of_file(tmpdir): def test_ok_with_dos_line_endings(tmpdir): filename = tmpdir.join('f') filename.write_binary(b'foo\r\nbar\r\nbaz\r\n') - ret = main((filename.strpath,)) + ret = main((str(filename),)) assert filename.read_binary() == b'foo\r\nbar\r\nbaz\r\n' assert ret == 0 @@ -43,7 +43,7 @@ def test_fixes_markdown_files(tmpdir, ext): '\t\n' # trailing tabs are stripped anyway '\n ', # whitespace at the end of the file is removed ) - ret = main((path.strpath, f'--markdown-linebreak-ext={ext}')) + ret = main((str(path), f'--markdown-linebreak-ext={ext}')) assert ret == 1 assert path.read() == ( 'foo \n' @@ -63,7 +63,7 @@ def test_markdown_linebreak_ext_badopt(arg): def test_prints_warning_with_no_markdown_ext(capsys, tmpdir): f = tmpdir.join('f').ensure() - assert main((f.strpath, '--no-markdown-linebreak-ext')) == 0 + assert main((str(f), '--no-markdown-linebreak-ext')) == 0 out, _ = capsys.readouterr() assert out == '--no-markdown-linebreak-ext now does nothing!\n' @@ -72,7 +72,7 @@ def test_preserve_non_utf8_file(tmpdir): non_utf8_bytes_content = b'\xe9 \n\n' path = tmpdir.join('file.txt') path.write_binary(non_utf8_bytes_content) - ret = main([path.strpath]) + ret = main([str(path)]) assert ret == 1 assert path.size() == (len(non_utf8_bytes_content) - 1) @@ -81,7 +81,7 @@ def test_custom_charset_change(tmpdir): # strip spaces only, no tabs path = tmpdir.join('file.txt') path.write('\ta \t \n') - ret = main([path.strpath, '--chars', ' ']) + ret = main([str(path), '--chars', ' ']) assert ret == 1 assert path.read() == '\ta \t\n' @@ -89,13 +89,13 @@ def test_custom_charset_change(tmpdir): def test_custom_charset_no_change(tmpdir): path = tmpdir.join('file.txt') path.write('\ta \t\n') - ret = main([path.strpath, '--chars', ' ']) + ret = main([str(path), '--chars', ' ']) assert ret == 0 def test_markdown_with_custom_charset(tmpdir): path = tmpdir.join('file.md') path.write('\ta \t \n') - ret = main([path.strpath, '--chars', ' ', '--markdown-linebreak-ext', '*']) + ret = main([str(path), '--chars', ' ', '--markdown-linebreak-ext', '*']) assert ret == 1 assert path.read() == '\ta \t \n'