mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
Fix up merge request 78
This simplifies the changes, reduces the scope of refactors apparently for refactoring's sake and ensures that the internals are reasonable. It also airs on the side of preserving information rather than discarding or overwriting it.
This commit is contained in:
parent
7934f8dce2
commit
a1fdb5a2b5
5 changed files with 54 additions and 45 deletions
|
|
@ -14,7 +14,7 @@ def options_from(**kwargs):
|
|||
kwargs.setdefault('hang_closing', True)
|
||||
kwargs.setdefault('max_line_length', 79)
|
||||
kwargs.setdefault('verbose', False)
|
||||
kwargs.setdefault('stdin_display_name', None)
|
||||
kwargs.setdefault('stdin_display_name', 'stdin')
|
||||
return optparse.Values(kwargs)
|
||||
|
||||
|
||||
|
|
@ -71,10 +71,18 @@ def test_stdin_filename_attribute(stdin_get_value):
|
|||
stdin_get_value.return_value = stdin_value
|
||||
file_processor = processor.FileProcessor('-', options_from())
|
||||
assert file_processor.filename == 'stdin'
|
||||
|
||||
|
||||
@mock.patch('flake8.utils.stdin_get_value')
|
||||
def test_read_lines_uses_display_name(stdin_get_value):
|
||||
"""Verify that when processing stdin we use a display name if present."""
|
||||
stdin_value = mock.Mock()
|
||||
stdin_value.splitlines.return_value = []
|
||||
stdin_get_value.return_value = stdin_value
|
||||
file_processor = processor.FileProcessor('-', options_from(
|
||||
stdin_display_name="foo.py"
|
||||
stdin_display_name='display_name.py'
|
||||
))
|
||||
assert file_processor.filename == 'foo.py'
|
||||
assert file_processor.filename == 'display_name.py'
|
||||
|
||||
|
||||
def test_line_for():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue