55import os
66import os .path
77import re
8- import pkg_resources
98import subprocess
109import stat
1110from plumbum import local
1817from pre_commit .commands .install_uninstall import make_executable
1918from pre_commit .commands .install_uninstall import uninstall
2019from pre_commit .runner import Runner
20+ from pre_commit .util import resource_filename
2121from testing .fixtures import git_dir
2222from testing .fixtures import make_consuming_repo
2323
@@ -27,23 +27,15 @@ def test_is_not_our_pre_commit():
2727
2828
2929def test_is_our_pre_commit ():
30- assert is_our_pre_commit (
31- pkg_resources .resource_filename (
32- 'pre_commit' , 'resources/pre-commit-hook' ,
33- )
34- ) is True
30+ assert is_our_pre_commit (resource_filename ('pre-commit-hook' ))
3531
3632
3733def test_is_not_previous_pre_commit ():
3834 assert is_previous_pre_commit ('setup.py' ) is False
3935
4036
4137def test_is_also_not_previous_pre_commit ():
42- assert is_previous_pre_commit (
43- pkg_resources .resource_filename (
44- 'pre_commit' , 'resources/pre-commit-hook' ,
45- )
46- ) is False
38+ assert not is_previous_pre_commit (resource_filename ('pre-commit-hook' ))
4739
4840
4941def test_is_previous_pre_commit (in_tmpdir ):
@@ -60,9 +52,7 @@ def test_install_pre_commit(tmpdir_factory):
6052 assert ret == 0
6153 assert os .path .exists (runner .pre_commit_path )
6254 pre_commit_contents = io .open (runner .pre_commit_path ).read ()
63- pre_commit_script = pkg_resources .resource_filename (
64- 'pre_commit' , 'resources/pre-commit-hook' ,
65- )
55+ pre_commit_script = resource_filename ('pre-commit-hook' )
6656 expected_contents = io .open (pre_commit_script ).read ()
6757 assert pre_commit_contents == expected_contents
6858 stat_result = os .stat (runner .pre_commit_path )
@@ -317,9 +307,7 @@ def test_replace_old_commit_script(tmpdir_factory):
317307
318308 # Install a script that looks like our old script
319309 pre_commit_contents = io .open (
320- pkg_resources .resource_filename (
321- 'pre_commit' , 'resources/pre-commit-hook' ,
322- )
310+ resource_filename ('pre-commit-hook' ),
323311 ).read ()
324312 new_contents = pre_commit_contents .replace (
325313 IDENTIFYING_HASH , PREVIOUS_IDENTIFYING_HASHES [- 1 ],
0 commit comments