mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 23:34:17 +00:00
Add tests for parse_unified_diff
We could probably use non-git diff fixtures, but those are what we have for now.
This commit is contained in:
parent
02bcbee245
commit
9ebaa5c69c
5 changed files with 243 additions and 3 deletions
27
tests/fixtures/diffs/single_file_diff
vendored
Normal file
27
tests/fixtures/diffs/single_file_diff
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
diff --git a/flake8/utils.py b/flake8/utils.py
|
||||
index f6ce384..7cd12b0 100644
|
||||
--- a/flake8/utils.py
|
||||
+++ b/flake8/utils.py
|
||||
@@ -75,8 +75,8 @@ def stdin_get_value():
|
||||
return cached_value.getvalue()
|
||||
|
||||
|
||||
-def parse_unified_diff():
|
||||
- # type: () -> List[str]
|
||||
+def parse_unified_diff(diff=None):
|
||||
+ # type: (str) -> List[str]
|
||||
"""Parse the unified diff passed on stdin.
|
||||
|
||||
:returns:
|
||||
@@ -84,7 +84,10 @@ def parse_unified_diff():
|
||||
:rtype:
|
||||
dict
|
||||
"""
|
||||
- diff = stdin_get_value()
|
||||
+ # Allow us to not have to patch out stdin_get_value
|
||||
+ if diff is None:
|
||||
+ diff = stdin_get_value()
|
||||
+
|
||||
number_of_rows = None
|
||||
current_path = None
|
||||
parsed_paths = collections.defaultdict(set)
|
||||
Loading…
Add table
Add a link
Reference in a new issue