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:
Ian Cordasco 2016-07-20 19:28:13 -05:00
parent 7934f8dce2
commit a1fdb5a2b5
No known key found for this signature in database
GPG key ID: 656D3395E4A9791A
5 changed files with 54 additions and 45 deletions

View file

@ -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():