1diff --git a/flake8/utils.py b/flake8/utils.py 2index f6ce384..7cd12b0 100644 3--- a/flake8/utils.py 4+++ b/flake8/utils.py 5@@ -75,8 +75,8 @@ def stdin_get_value(): 6 return cached_value.getvalue() 7 8 9-def parse_unified_diff(): 10- # type: () -> List[str] 11+def parse_unified_diff(diff=None): 12+ # type: (str) -> List[str] 13 """Parse the unified diff passed on stdin. 14 15 :returns: 16@@ -84,7 +84,10 @@ def parse_unified_diff(): 17 :rtype: 18 dict 19 """ 20- diff = stdin_get_value() 21+ # Allow us to not have to patch out stdin_get_value 22+ if diff is None: 23+ diff = stdin_get_value() 24+ 25 number_of_rows = None 26 current_path = None 27 parsed_paths = collections.defaultdict(set) 28diff --git a/tests/fixtures/diffs/single_file_diff b/tests/fixtures/diffs/single_file_diff 29new file mode 100644 30index 0000000..77ca534 31--- /dev/null 32+++ b/tests/fixtures/diffs/single_file_diff 33@@ -0,0 +1,27 @@ 34+diff --git a/flake8/utils.py b/flake8/utils.py 35+index f6ce384..7cd12b0 100644 36+--- a/flake8/utils.py 37++++ b/flake8/utils.py 38+@@ -75,8 +75,8 @@ def stdin_get_value(): 39+ return cached_value.getvalue() 40+ 41+ 42+-def parse_unified_diff(): 43+- # type: () -> List[str] 44++def parse_unified_diff(diff=None): 45++ # type: (str) -> List[str] 46+ """Parse the unified diff passed on stdin. 47+ 48+ :returns: 49+@@ -84,7 +84,10 @@ def parse_unified_diff(): 50+ :rtype: 51+ dict 52+ """ 53+- diff = stdin_get_value() 54++ # Allow us to not have to patch out stdin_get_value 55++ if diff is None: 56++ diff = stdin_get_value() 57++ 58+ number_of_rows = None 59+ current_path = None 60+ parsed_paths = collections.defaultdict(set) 61diff --git a/tests/fixtures/diffs/two_file_diff b/tests/fixtures/diffs/two_file_diff 62new file mode 100644 63index 0000000..5bd35cd 64--- /dev/null 65+++ b/tests/fixtures/diffs/two_file_diff 66@@ -0,0 +1,45 @@ 67+diff --git a/flake8/utils.py b/flake8/utils.py 68+index f6ce384..7cd12b0 100644 69+--- a/flake8/utils.py 70++++ b/flake8/utils.py 71+@@ -75,8 +75,8 @@ def stdin_get_value(): 72+ return cached_value.getvalue() 73+ 74+ 75+-def parse_unified_diff(): 76+- # type: () -> List[str] 77++def parse_unified_diff(diff=None): 78++ # type: (str) -> List[str] 79+ """Parse the unified diff passed on stdin. 80+ 81+ :returns: 82+@@ -84,7 +84,10 @@ def parse_unified_diff(): 83+ :rtype: 84+ dict 85+ """ 86+- diff = stdin_get_value() 87++ # Allow us to not have to patch out stdin_get_value 88++ if diff is None: 89++ diff = stdin_get_value() 90++ 91+ number_of_rows = None 92+ current_path = None 93+ parsed_paths = collections.defaultdict(set) 94+diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py 95+index d69d939..21482ce 100644 96+--- a/tests/unit/test_utils.py 97++++ b/tests/unit/test_utils.py 98+@@ -115,3 +115,13 @@ def test_parameters_for_function_plugin(): 99+ plugin = plugin_manager.Plugin('plugin-name', object()) 100+ plugin._plugin = fake_plugin 101+ assert utils.parameters_for(plugin) == ['physical_line', 'self', 'tree'] 102++ 103++ 104++def read_diff_file(filename): 105++ """Read the diff file in its entirety.""" 106++ with open(filename, 'r') as fd: 107++ content = fd.read() 108++ return content 109++ 110++ 111++SINGLE_FILE_DIFF = read_diff_file('tests/fixtures/diffs/single_file_diff') 112diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py 113index d69d939..1461369 100644 114--- a/tests/unit/test_utils.py 115+++ b/tests/unit/test_utils.py 116@@ -115,3 +115,14 @@ def test_parameters_for_function_plugin(): 117 plugin = plugin_manager.Plugin('plugin-name', object()) 118 plugin._plugin = fake_plugin 119 assert utils.parameters_for(plugin) == ['physical_line', 'self', 'tree'] 120+ 121+ 122+def read_diff_file(filename): 123+ """Read the diff file in its entirety.""" 124+ with open(filename, 'r') as fd: 125+ content = fd.read() 126+ return content 127+ 128+ 129+SINGLE_FILE_DIFF = read_diff_file('tests/fixtures/diffs/single_file_diff') 130+TWO_FILE_DIFF = read_diff_file('tests/fixtures/diffs/two_file_diff') 131