Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 7862d77

Browse files
committed
Fixed Python 2.6 errors.
1 parent 857a28a commit 7862d77

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pep257.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def check(filenames, select=None, ignore=None):
726726

727727
def get_options(args, opt_parser):
728728
config = RawConfigParser()
729-
parent = tail = args and os.path.abspath(os.path.commonprefix(args))
729+
parent = tail = os.path.abspath(os.path.commonprefix(args))
730730
while tail:
731731
for fn in PROJECT_CONFIG:
732732
full_path = os.path.join(parent, fn)
@@ -811,7 +811,7 @@ def validate_options(options):
811811
mutually_exclusive = ('ignore', 'select', 'convention')
812812
for opt1, opt2 in itertools.permutations(mutually_exclusive, 2):
813813
if getattr(options, opt1) and getattr(options, opt2):
814-
log.error('Cannot pass both {} and {}. They are '
814+
log.error('Cannot pass both {0} and {1}. They are '
815815
'mutually exclusive.'.format(opt1, opt2))
816816
return False
817817
if options.convention and not hasattr(Conventions, options.convention):

test_pep257.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def function_with_bad_docstring(foo):
9393
error_codes = set(error.code for error in errors)
9494
assert error_codes == expected_error_codes
9595

96+
# We need to recreate the mock, otherwise the read file is empty
97+
mock_open = mock.mock_open(read_data=function_to_check)
98+
with mock.patch('pep257.tokenize_open', mock_open, create=True):
9699
errors = tuple(pep257.check(['filepath'], ignore=['D100', 'D202']))
97100
error_codes = set(error.code for error in errors)
98101
assert error_codes == expected_error_codes - set(('D100', 'D202'))

0 commit comments

Comments
 (0)