mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-02 11:56:52 +00:00
Add a regression test for EPIPE IOErrors
This should prevent bug 69 from regressing in the future and provides a framework for testing the addition of new errnos to the ingore list.
This commit is contained in:
parent
d98e1729b3
commit
1ed78df61e
1 changed files with 36 additions and 0 deletions
36
flake8/tests/test_reporter.py
Normal file
36
flake8/tests/test_reporter.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
import errno
|
||||
import unittest
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock # < PY33
|
||||
|
||||
from flake8 import reporter
|
||||
|
||||
|
||||
def ioerror_report_factory(errno_code):
|
||||
class IOErrorBaseQReport(reporter.BaseQReport):
|
||||
def _process_main(self):
|
||||
raise IOError(errno_code, 'Fake bad pipe exception')
|
||||
|
||||
options = mock.MagicMock()
|
||||
options.jobs = 2
|
||||
return IOErrorBaseQReport(options)
|
||||
|
||||
|
||||
class TestBaseQReport(unittest.TestCase):
|
||||
def test_does_not_raise_a_bad_pipe_ioerror(self):
|
||||
"""Test that no EPIPE IOError exception is re-raised or leaked."""
|
||||
report = ioerror_report_factory(errno.EPIPE)
|
||||
try:
|
||||
report.process_main()
|
||||
except IOError:
|
||||
self.fail('BaseQReport.process_main raised an IOError for EPIPE'
|
||||
' but it should have caught this exception.')
|
||||
|
||||
def test_raises_a_enoent_ioerror(self):
|
||||
"""Test that an ENOENT IOError exception is re-raised."""
|
||||
report = ioerror_report_factory(errno.ENOENT)
|
||||
self.assertRaises(IOError, report.process_main)
|
||||
Loading…
Add table
Add a link
Reference in a new issue