mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 07:14:18 +00:00
Shorten variable name. Add comments
This commit is contained in:
parent
02308dab2a
commit
5dffadd67b
1 changed files with 9 additions and 11 deletions
|
|
@ -17,21 +17,18 @@ def excluded(filename):
|
||||||
|
|
||||||
class TestGitHook(unittest.TestCase):
|
class TestGitHook(unittest.TestCase):
|
||||||
if is_windows:
|
if is_windows:
|
||||||
|
# On Windows, absolute paths start with a drive letter, for example C:
|
||||||
|
# Here we build a fake absolute path starting with the current drive
|
||||||
|
# letter, for example C:\fake\temp
|
||||||
current_drive, ignore_tail = os.path.splitdrive(os.getcwd())
|
current_drive, ignore_tail = os.path.splitdrive(os.getcwd())
|
||||||
fake_path_at_root_of_filesystem = os.path.join(current_drive,
|
fake_abs_path = os.path.join(current_drive, os.path.sep, 'fake', 'tmp')
|
||||||
os.path.sep,
|
|
||||||
'fake',
|
|
||||||
'tmp')
|
|
||||||
else:
|
else:
|
||||||
fake_path_at_root_of_filesystem = os.path.join(os.path.sep,
|
fake_abs_path = os.path.join(os.path.sep, 'fake', 'tmp')
|
||||||
'fake',
|
|
||||||
'tmp')
|
|
||||||
|
|
||||||
@mock.patch('os.makedirs')
|
@mock.patch('os.makedirs')
|
||||||
@mock.patch('flake8.hooks.open', create=True)
|
@mock.patch('flake8.hooks.open', create=True)
|
||||||
@mock.patch('shutil.rmtree')
|
@mock.patch('shutil.rmtree')
|
||||||
@mock.patch('tempfile.mkdtemp',
|
@mock.patch('tempfile.mkdtemp', return_value=fake_abs_path)
|
||||||
return_value=fake_path_at_root_of_filesystem)
|
|
||||||
@mock.patch('flake8.hooks.run',
|
@mock.patch('flake8.hooks.run',
|
||||||
return_value=(None,
|
return_value=(None,
|
||||||
[os.path.join('foo', 'afile.py'),
|
[os.path.join('foo', 'afile.py'),
|
||||||
|
|
@ -50,9 +47,10 @@ class TestGitHook(unittest.TestCase):
|
||||||
dirname, filename = os.path.split(
|
dirname, filename = os.path.split(
|
||||||
os.path.abspath(os.path.join('foo', 'bfile.py')))
|
os.path.abspath(os.path.join('foo', 'bfile.py')))
|
||||||
if is_windows:
|
if is_windows:
|
||||||
|
# In Windows, the absolute path in dirname will start with a drive
|
||||||
|
# letter. Here, we discad the drive letter.
|
||||||
ignore_drive, dirname = os.path.splitdrive(dirname)
|
ignore_drive, dirname = os.path.splitdrive(dirname)
|
||||||
tmpdir = os.path.join(self.fake_path_at_root_of_filesystem,
|
tmpdir = os.path.join(self.fake_abs_path, dirname[1:])
|
||||||
dirname[1:])
|
|
||||||
tmpfile = os.path.join(tmpdir, 'bfile.py')
|
tmpfile = os.path.join(tmpdir, 'bfile.py')
|
||||||
style_guide.check_files.assert_called_once_with([tmpfile])
|
style_guide.check_files.assert_called_once_with([tmpfile])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue