summaryrefslogtreecommitdiff
path: root/flake8/tests
diff options
context:
space:
mode:
Diffstat (limited to 'flake8/tests')
-rw-r--r--flake8/tests/__init__.py1
-rw-r--r--flake8/tests/_test_warnings.py309
-rw-r--r--flake8/tests/test_engine.py236
-rw-r--r--flake8/tests/test_hooks.py59
-rw-r--r--flake8/tests/test_integration.py79
-rw-r--r--flake8/tests/test_main.py18
-rw-r--r--flake8/tests/test_pyflakes.py73
-rw-r--r--flake8/tests/test_reporter.py36
-rw-r--r--flake8/tests/test_util.py121
9 files changed, 0 insertions, 932 deletions
diff --git a/flake8/tests/__init__.py b/flake8/tests/__init__.py
deleted file mode 100644
index 792d600..0000000
--- a/flake8/tests/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-#
diff --git a/flake8/tests/_test_warnings.py b/flake8/tests/_test_warnings.py
deleted file mode 100644
index e329199..0000000
--- a/flake8/tests/_test_warnings.py
+++ /dev/null
@@ -1,309 +0,0 @@
-"""
- _test_warnings.py
-
- Tests for the warnings that are emitted by flake8.
-
- This module is named _test_warnings instead of test_warnings so that a
- normal nosetests run does not collect it. The tests in this module pass
- when they are run alone, but they fail when they are run along with other
- tests (nosetests --with-isolation doesn't help).
-
- In tox.ini, these tests are run separately.
-
-"""
-
-from __future__ import with_statement
-
-import os
-import warnings
-import unittest
-try:
- from unittest import mock
-except ImportError:
- import mock # < PY33
-
-from flake8 import engine
-from flake8.util import is_windows
-
-# The Problem
-# ------------
-#
-# Some of the tests in this module pass when this module is run on its own, but
-# they fail when this module is run as part of the whole test suite. These are
-# the problematic tests:
-#
-# test_jobs_verbose
-# test_stdin_jobs_warning
-#
-# On some platforms, the warnings.capture_warnings function doesn't work
-# properly when run with the other flake8 tests. It drops some warnings, even
-# though the warnings filter is set to 'always'. However, when run separately,
-# these tests pass.
-#
-# This problem only occurs on Windows, with Python 3.3 and older. Maybe it's
-# related to PEP 446 - Inheritable file descriptors?
-#
-#
-#
-#
-# Things that didn't work
-# ------------
-#
-# Nose --attr
-# I tried using the nosetests --attr feature to run the tests separately. I
-# put the following in setup.cfg
-#
-# [nosetests]
-# atttr=!run_alone
-#
-# Then I added a tox section thst did this
-#
-# nosetests --attr=run_alone
-#
-# However, the command line --attr would not override the config file --attr,
-# so the special tox section wound up runing all the tests, and failing.
-#
-#
-#
-# Nose --with-isolation
-# The nosetests --with-isolation flag did not help.
-#
-#
-#
-# unittest.skipIf
-# I tried decorating the problematic tests with the unittest.skipIf
-# decorator.
-#
-# @unittest.skipIf(is_windows() and sys.version_info < (3, 4),
-# "Fails on Windows with Python < 3.4 when run with other"
-# " tests.")
-#
-# The idea is, skip the tests in the main test run, on affected platforms.
-# Then, only on those platforms, come back in later and run the tests
-# separately.
-#
-# I added a new stanza to tox.ini, to run the tests separately on the
-# affected platforms.
-#
-# nosetests --no-skip
-#
-# I ran in to a bug in the nosetests skip plugin. It would report the test as
-# having been run, but it would not actually run the test. So, when run with
-# --no-skip, the following test would be reported as having run and passed!
-#
-# @unittest.skip("This passes o_o")
-# def test_should_fail(self):
-# assert 0
-#
-# This bug has been reported here:
-# "--no-skip broken with Python 2.7"
-# https://github.com/nose-devs/nose/issues/512
-#
-#
-#
-# py.test
-#
-# I tried using py.test, and its @pytest.mark.xfail decorator. I added some
-# separate stanzas in tox, and useing the pytest --runxfail option to run the
-# tests separately. This allows us to run all the tests together, on
-# platforms that allow it. On platforms that don't allow us to run the tests
-# all together, this still runs all the tests, but in two separate steps.
-#
-# This is the same solution as the nosetests --no-skip solution I described
-# above, but --runxfail does not have the same bug as --no-skip.
-#
-# This has the advantage that all tests are discoverable by default, outside
-# of tox. However, nose does not recognize the pytest.mark.xfail decorator.
-# So, if a user runs nosetests, it still tries to run the problematic tests
-# together with the rest of the test suite, causing them to fail.
-#
-#
-#
-#
-#
-#
-# Solution
-# ------------
-# Move the problematic tests to _test_warnings.py, so nose.collector will not
-# find them. Set up a separate section in tox.ini that runs this:
-#
-# nosetests flake8.tests._test_warnings
-#
-# This allows all tests to pass on all platforms, when run through tox.
-# However, it means that, even on unaffected platforms, the problematic tests
-# are not discovered and run outside of tox (if the user just runs nosetests
-# manually, for example).
-
-
-class IntegrationTestCaseWarnings(unittest.TestCase):
- """Integration style tests to check that warnings are issued properly for
- different command line options."""
-
- windows_warning_text = ("The --jobs option is not available on Windows."
- " Ignoring --jobs arguments.")
- stdin_warning_text = ("The --jobs option is not compatible with"
- " supplying input using - . Ignoring --jobs"
- " arguments.")
-
- def this_file(self):
- """Return the real path of this file."""
- this_file = os.path.realpath(__file__)
- if this_file.endswith("pyc"):
- this_file = this_file[:-1]
- return this_file
-
- @staticmethod
- def get_style_guide_with_warnings(engine, *args, **kwargs):
- """
- Return a style guide object (obtained by calling
- engine.get_style_guide) and a list of the warnings that were raised in
- the process.
-
- Note: not threadsafe
- """
-
- # Note
- # https://docs.python.org/2/library/warnings.html
- #
- # The catch_warnings manager works by replacing and then later
- # restoring the module's showwarning() function and internal list of
- # filter specifications. This means the context manager is modifying
- # global state and therefore is not thread-safe
-
- with warnings.catch_warnings(record=True) as collected_warnings:
- # Cause all warnings to always be triggered.
- warnings.simplefilter("always")
-
- # Get the style guide
- style_guide = engine.get_style_guide(*args, **kwargs)
-
- # Now that the warnings have been collected, return the style guide and
- # the warnings.
- return (style_guide, collected_warnings)
-
- def verify_warnings(self, collected_warnings, expected_warnings):
- """
- Verifies that collected_warnings is a sequence that contains user
- warnings that match the sequence of string values passed in as
- expected_warnings.
- """
- if expected_warnings is None:
- expected_warnings = []
-
- collected_user_warnings = [w for w in collected_warnings
- if issubclass(w.category, UserWarning)]
-
- self.assertEqual(len(collected_user_warnings),
- len(expected_warnings))
-
- collected_warnings_set = set(str(warning.message)
- for warning
- in collected_user_warnings)
- expected_warnings_set = set(expected_warnings)
- self.assertEqual(collected_warnings_set, expected_warnings_set)
-
- def check_files_collect_warnings(self,
- arglist=[],
- explicit_stdin=False,
- count=0,
- verbose=False):
- """Call check_files and collect any warnings that are issued."""
- if verbose:
- arglist.append('--verbose')
- if explicit_stdin:
- target_file = "-"
- else:
- target_file = self.this_file()
- argv = ['flake8'] + arglist + [target_file]
- with mock.patch("sys.argv", argv):
- (style_guide,
- collected_warnings,
- ) = self.get_style_guide_with_warnings(engine,
- parse_argv=True)
- report = style_guide.check_files()
- self.assertEqual(report.total_errors, count)
- return style_guide, report, collected_warnings
-
- def check_files_no_warnings_allowed(self,
- arglist=[],
- explicit_stdin=False,
- count=0,
- verbose=False):
- """Call check_files, and assert that there were no warnings issued."""
- (style_guide,
- report,
- collected_warnings,
- ) = self.check_files_collect_warnings(arglist=arglist,
- explicit_stdin=explicit_stdin,
- count=count,
- verbose=verbose)
- self.verify_warnings(collected_warnings, expected_warnings=None)
- return style_guide, report
-
- def _job_tester(self, jobs, verbose=False):
- # mock stdout.flush so we can count the number of jobs created
- with mock.patch('sys.stdout.flush') as mocked:
- (guide,
- report,
- collected_warnings,
- ) = self.check_files_collect_warnings(
- arglist=['--jobs=%s' % jobs],
- verbose=verbose)
-
- if is_windows():
- # The code path where guide.options.jobs gets converted to an
- # int is not run on windows. So, do the int conversion here.
- self.assertEqual(int(guide.options.jobs), jobs)
- # On windows, call count is always zero.
- self.assertEqual(mocked.call_count, 0)
- else:
- self.assertEqual(guide.options.jobs, jobs)
- self.assertEqual(mocked.call_count, jobs)
-
- expected_warings = []
- if verbose and is_windows():
- expected_warings.append(self.windows_warning_text)
- self.verify_warnings(collected_warnings, expected_warings)
-
- def test_jobs(self, verbose=False):
- self._job_tester(2, verbose=verbose)
- self._job_tester(10, verbose=verbose)
-
- def test_no_args_no_warnings(self, verbose=False):
- self.check_files_no_warnings_allowed(verbose=verbose)
-
- def test_stdin_jobs_warning(self, verbose=False):
- self.count = 0
-
- def fake_stdin():
- self.count += 1
- with open(self.this_file(), "r") as f:
- return f.read()
-
- with mock.patch("pycodestyle.stdin_get_value", fake_stdin):
- (style_guide,
- report,
- collected_warnings,
- ) = self.check_files_collect_warnings(arglist=['--jobs=4'],
- explicit_stdin=True,
- verbose=verbose)
- expected_warings = []
- if verbose:
- expected_warings.append(self.stdin_warning_text)
- if is_windows():
- expected_warings.append(self.windows_warning_text)
- self.verify_warnings(collected_warnings, expected_warings)
- self.assertEqual(self.count, 1)
-
- def test_jobs_verbose(self):
- self.test_jobs(verbose=True)
-
- def test_no_args_no_warnings_verbose(self):
- self.test_no_args_no_warnings(verbose=True)
-
- def test_stdin_jobs_warning_verbose(self):
- self.test_stdin_jobs_warning(verbose=True)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/flake8/tests/test_engine.py b/flake8/tests/test_engine.py
deleted file mode 100644
index 5feafe1..0000000
--- a/flake8/tests/test_engine.py
+++ /dev/null
@@ -1,236 +0,0 @@
-from __future__ import with_statement
-
-import errno
-import unittest
-try:
- from unittest import mock
-except ImportError:
- import mock # < PY33
-
-from flake8 import engine, util, __version__, reporter
-import pycodestyle as pep8
-
-
-class TestEngine(unittest.TestCase):
- def setUp(self):
- self.patches = {}
-
- def tearDown(self):
- assert len(self.patches.items()) == 0
-
- def start_patch(self, patch):
- self.patches[patch] = mock.patch(patch)
- return self.patches[patch].start()
-
- def stop_patches(self):
- patches = self.patches.copy()
- for k, v in patches.items():
- v.stop()
- del(self.patches[k])
-
- def test_get_style_guide(self):
- with mock.patch('flake8.engine._register_extensions') as reg_ext:
- reg_ext.return_value = ([], [], [], [])
- g = engine.get_style_guide()
- self.assertTrue(isinstance(g, engine.StyleGuide))
- reg_ext.assert_called_once_with()
-
- def test_get_style_guide_kwargs(self):
- m = mock.Mock()
- with mock.patch('flake8.engine.StyleGuide') as StyleGuide:
- with mock.patch('flake8.engine.get_parser') as get_parser:
- m.ignored_extensions = []
- StyleGuide.return_value.options.jobs = '42'
- StyleGuide.return_value.options.diff = False
- get_parser.return_value = (m, [])
- engine.get_style_guide(foo='bar')
- get_parser.assert_called_once_with()
- StyleGuide.assert_called_once_with(**{'parser': m, 'foo': 'bar'})
-
- def test_register_extensions(self):
- with mock.patch('pycodestyle.register_check') as register_check:
- registered_exts = engine._register_extensions()
- self.assertTrue(isinstance(registered_exts[0], util.OrderedSet))
- self.assertTrue(len(registered_exts[0]) > 0)
- for i in registered_exts[1:]:
- self.assertTrue(isinstance(i, list))
- self.assertTrue(register_check.called)
-
- def test_disable_extensions(self):
- parser = mock.MagicMock()
- options = mock.MagicMock()
-
- parser.ignored_extensions = ['I123', 'I345', 'I678', 'I910']
-
- options.enable_extensions = 'I345,\nI678,I910'
- options.ignore = ('E121', 'E123')
-
- engine._disable_extensions(parser, options)
- self.assertEqual(set(options.ignore), set(['E121', 'E123', 'I123']))
-
- def test_get_parser(self):
- # setup
- re = self.start_patch('flake8.engine._register_extensions')
- gpv = self.start_patch('flake8.engine.get_python_version')
- pgp = self.start_patch('pycodestyle.get_parser')
- m = mock.Mock()
- re.return_value = ([('pyflakes', '0.7'), ('mccabe', '0.2')], [], [],
- [])
- gpv.return_value = 'Python Version'
- pgp.return_value = m
- # actual call we're testing
- parser, hooks = engine.get_parser()
- # assertions
- self.assertTrue(re.called)
- self.assertTrue(gpv.called)
- pgp.assert_called_once_with(
- 'flake8',
- '%s (pyflakes: 0.7, mccabe: 0.2) Python Version' % __version__)
- self.assertTrue(m.remove_option.called)
- self.assertTrue(m.add_option.called)
- self.assertEqual(parser, m)
- self.assertEqual(hooks, [])
- # clean-up
- self.stop_patches()
-
- def test_get_python_version(self):
- self.assertTrue('on' in engine.get_python_version())
- # Silly test but it will provide 100% test coverage
- # Also we can never be sure (without reconstructing the string
- # ourselves) what system we may be testing on.
-
- def test_windows_disables_jobs(self):
- with mock.patch('flake8.util.is_windows') as is_windows:
- is_windows.return_value = True
- guide = engine.get_style_guide()
- assert isinstance(guide, reporter.BaseQReport) is False
-
- def test_stdin_disables_jobs(self):
- with mock.patch('flake8.util.is_using_stdin') as is_using_stdin:
- is_using_stdin.return_value = True
- guide = engine.get_style_guide()
- assert isinstance(guide, reporter.BaseQReport) is False
-
- def test_disables_extensions_that_are_not_selected(self):
- with mock.patch('flake8.engine._register_extensions') as re:
- re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X'])
- sg = engine.get_style_guide()
- assert 'X' in sg.options.ignore
-
- def test_enables_off_by_default_extensions(self):
- with mock.patch('flake8.engine._register_extensions') as re:
- re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X'])
- parser, options = engine.get_parser()
- parser.parse_args(['--select=X'])
- sg = engine.StyleGuide(parser=parser)
- assert 'X' not in sg.options.ignore
-
- def test_load_entry_point_verifies_requirements(self):
- entry_point = mock.Mock(spec=['require', 'resolve', 'load'])
-
- engine._load_entry_point(entry_point, verify_requirements=True)
- entry_point.require.assert_called_once_with()
- entry_point.resolve.assert_called_once_with()
-
- def test_load_entry_point_does_not_verify_requirements(self):
- entry_point = mock.Mock(spec=['require', 'resolve', 'load'])
-
- engine._load_entry_point(entry_point, verify_requirements=False)
- self.assertFalse(entry_point.require.called)
- entry_point.resolve.assert_called_once_with()
-
- def test_load_entry_point_passes_require_argument_to_load(self):
- entry_point = mock.Mock(spec=['load'])
-
- engine._load_entry_point(entry_point, verify_requirements=True)
- entry_point.load.assert_called_once_with(require=True)
- entry_point.reset_mock()
-
- engine._load_entry_point(entry_point, verify_requirements=False)
- entry_point.load.assert_called_once_with(require=False)
-
-
-def oserror_generator(error_number, message='Ominous OSError message'):
- def oserror_side_effect(*args, **kwargs):
- if hasattr(oserror_side_effect, 'used'):
- return
-
- oserror_side_effect.used = True
- raise OSError(error_number, message)
-
- return oserror_side_effect
-
-
-class TestStyleGuide(unittest.TestCase):
- def setUp(self):
- mocked_styleguide = mock.Mock(spec=engine.NoQAStyleGuide)
- self.styleguide = engine.StyleGuide(styleguide=mocked_styleguide)
- self.mocked_sg = mocked_styleguide
-
- def test_proxies_excluded(self):
- self.styleguide.excluded('file.py', parent='.')
-
- self.mocked_sg.excluded.assert_called_once_with('file.py', parent='.')
-
- def test_proxies_init_report(self):
- reporter = object()
- self.styleguide.init_report(reporter)
-
- self.mocked_sg.init_report.assert_called_once_with(reporter)
-
- def test_proxies_check_files(self):
- self.styleguide.check_files(['foo', 'bar'])
-
- self.mocked_sg.check_files.assert_called_once_with(
- paths=['foo', 'bar']
- )
-
- def test_proxies_input_file(self):
- self.styleguide.input_file('file.py',
- lines=[9, 10],
- expected='foo',
- line_offset=20)
-
- self.mocked_sg.input_file.assert_called_once_with(filename='file.py',
- lines=[9, 10],
- expected='foo',
- line_offset=20)
-
- def test_check_files_retries_on_specific_OSErrors(self):
- self.mocked_sg.check_files.side_effect = oserror_generator(
- errno.ENOSPC, 'No space left on device'
- )
-
- self.styleguide.check_files(['foo', 'bar'])
-
- self.mocked_sg.init_report.assert_called_once_with(pep8.StandardReport)
-
- def test_input_file_retries_on_specific_OSErrors(self):
- self.mocked_sg.input_file.side_effect = oserror_generator(
- errno.ENOSPC, 'No space left on device'
- )
-
- self.styleguide.input_file('file.py')
-
- self.mocked_sg.init_report.assert_called_once_with(pep8.StandardReport)
-
- def test_check_files_reraises_unknown_OSErrors(self):
- self.mocked_sg.check_files.side_effect = oserror_generator(
- errno.EADDRINUSE,
- 'lol why are we talking about binding to sockets'
- )
-
- self.assertRaises(OSError, self.styleguide.check_files,
- ['foo', 'bar'])
-
- def test_input_file_reraises_unknown_OSErrors(self):
- self.mocked_sg.input_file.side_effect = oserror_generator(
- errno.EADDRINUSE,
- 'lol why are we talking about binding to sockets'
- )
-
- self.assertRaises(OSError, self.styleguide.input_file,
- ['foo', 'bar'])
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/flake8/tests/test_hooks.py b/flake8/tests/test_hooks.py
deleted file mode 100644
index ba46794..0000000
--- a/flake8/tests/test_hooks.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""Module containing the tests for flake8.hooks."""
-import os
-import unittest
-
-try:
- from unittest import mock
-except ImportError:
- import mock
-
-import flake8.hooks
-from flake8.util import is_windows
-
-
-def excluded(filename):
- return filename.endswith('afile.py')
-
-
-class TestGitHook(unittest.TestCase):
- if is_windows:
- # On Windows, absolute paths start with a drive letter, for example C:
- # Here we build a fake absolute path starting with the current drive
- # letter, for example C:\fake\temp
- current_drive, ignore_tail = os.path.splitdrive(os.getcwd())
- fake_abs_path = os.path.join(current_drive, os.path.sep, 'fake', 'tmp')
- else:
- fake_abs_path = os.path.join(os.path.sep, 'fake', 'tmp')
-
- @mock.patch('os.makedirs')
- @mock.patch('flake8.hooks.open', create=True)
- @mock.patch('shutil.rmtree')
- @mock.patch('tempfile.mkdtemp', return_value=fake_abs_path)
- @mock.patch('flake8.hooks.run',
- return_value=(None,
- [os.path.join('foo', 'afile.py'),
- os.path.join('foo', 'bfile.py')],
- None))
- @mock.patch('flake8.hooks.get_style_guide')
- def test_prepends_tmp_directory_to_exclude(self, get_style_guide, run,
- *args):
- style_guide = get_style_guide.return_value = mock.Mock()
- style_guide.options.exclude = [os.path.join('foo', 'afile.py')]
- style_guide.options.filename = [os.path.join('foo', '*')]
- style_guide.excluded = excluded
-
- flake8.hooks.git_hook()
-
- dirname, filename = os.path.split(
- os.path.abspath(os.path.join('foo', 'bfile.py')))
- if is_windows:
- # In Windows, the absolute path in dirname will start with a drive
- # letter. Here, we discad the drive letter.
- ignore_drive, dirname = os.path.splitdrive(dirname)
- tmpdir = os.path.join(self.fake_abs_path, dirname[1:])
- tmpfile = os.path.join(tmpdir, 'bfile.py')
- style_guide.check_files.assert_called_once_with([tmpfile])
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/flake8/tests/test_integration.py b/flake8/tests/test_integration.py
deleted file mode 100644
index f82a769..0000000
--- a/flake8/tests/test_integration.py
+++ /dev/null
@@ -1,79 +0,0 @@
-from __future__ import with_statement
-
-import os
-import unittest
-try:
- from unittest import mock
-except ImportError:
- import mock # < PY33
-
-from flake8 import engine
-from flake8.util import is_windows
-
-
-class IntegrationTestCase(unittest.TestCase):
- """Integration style tests to exercise different command line options."""
-
- def this_file(self):
- """Return the real path of this file."""
- this_file = os.path.realpath(__file__)
- if this_file.endswith("pyc"):
- this_file = this_file[:-1]
- return this_file
-
- def check_files(self, arglist=[], explicit_stdin=False, count=0):
- """Call check_files."""
- if explicit_stdin:
- target_file = "-"
- else:
- target_file = self.this_file()
- argv = ['flake8'] + arglist + [target_file]
- with mock.patch("sys.argv", argv):
- style_guide = engine.get_style_guide(parse_argv=True)
- report = style_guide.check_files()
- self.assertEqual(report.total_errors, count)
- return style_guide, report
-
- def test_no_args(self):
- # assert there are no reported errors
- self.check_files()
-
- def _job_tester(self, jobs):
- # mock stdout.flush so we can count the number of jobs created
- with mock.patch('sys.stdout.flush') as mocked:
- guide, report = self.check_files(arglist=['--jobs=%s' % jobs])
- if is_windows():
- # The code path where guide.options.jobs gets converted to an
- # int is not run on windows. So, do the int conversion here.
- self.assertEqual(int(guide.options.jobs), jobs)
- # On windows, call count is always zero.
- self.assertEqual(mocked.call_count, 0)
- else:
- self.assertEqual(guide.options.jobs, jobs)
- self.assertEqual(mocked.call_count, jobs)
-
- def test_jobs(self):
- self._job_tester(2)
- self._job_tester(10)
-
- def test_stdin(self):
- self.count = 0
-
- def fake_stdin():
- self.count += 1
- with open(self.this_file(), "r") as f:
- return f.read()
-
- with mock.patch("pycodestyle.stdin_get_value", fake_stdin):
- guide, report = self.check_files(arglist=['--jobs=4'],
- explicit_stdin=True)
- self.assertEqual(self.count, 1)
-
- def test_stdin_fail(self):
- def fake_stdin():
- return "notathing\n"
- with mock.patch("pycodestyle.stdin_get_value", fake_stdin):
- # only assert needed is in check_files
- guide, report = self.check_files(arglist=['--jobs=4'],
- explicit_stdin=True,
- count=1)
diff --git a/flake8/tests/test_main.py b/flake8/tests/test_main.py
deleted file mode 100644
index af08093..0000000
--- a/flake8/tests/test_main.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from __future__ import with_statement
-
-import unittest
-
-import setuptools
-from flake8 import main
-
-
-class TestMain(unittest.TestCase):
- def test_issue_39_regression(self):
- distribution = setuptools.Distribution()
- cmd = main.Flake8Command(distribution)
- cmd.options_dict = {}
- cmd.run()
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/flake8/tests/test_pyflakes.py b/flake8/tests/test_pyflakes.py
deleted file mode 100644
index fb2f042..0000000
--- a/flake8/tests/test_pyflakes.py
+++ /dev/null
@@ -1,73 +0,0 @@
-from __future__ import with_statement
-
-import ast
-import unittest
-
-from collections import namedtuple
-
-from flake8._pyflakes import FlakesChecker
-
-Options = namedtuple("Options", ['builtins', 'doctests',
- 'include_in_doctest',
- 'exclude_from_doctest'])
-
-
-class TestFlakesChecker(unittest.TestCase):
-
- def setUp(self):
- self.tree = ast.parse('print("cookies")')
-
- def test_doctest_flag_enabled(self):
- options = Options(builtins=None, doctests=True,
- include_in_doctest='',
- exclude_from_doctest='')
- FlakesChecker.parse_options(options)
- flake_checker = FlakesChecker(self.tree, 'cookies.txt')
- assert flake_checker.withDoctest is True
-
- def test_doctest_flag_disabled(self):
- options = Options(builtins=None, doctests=False,
- include_in_doctest='',
- exclude_from_doctest='')
- FlakesChecker.parse_options(options)
- flake_checker = FlakesChecker(self.tree, 'cookies.txt')
- assert flake_checker.withDoctest is False
-
- def test_doctest_flag_enabled_exclude_file(self):
- options = Options(builtins=None, doctests=True,
- include_in_doctest='',
- exclude_from_doctest='cookies.txt,'
- 'hungry/cookies.txt')
- FlakesChecker.parse_options(options)
- flake_checker = FlakesChecker(self.tree, './cookies.txt')
- assert flake_checker.withDoctest is False
-
- def test_doctest_flag_disabled_include_file(self):
- options = Options(builtins=None, doctests=False,
- include_in_doctest='./cookies.txt,cake_yuck.txt',
- exclude_from_doctest='')
- FlakesChecker.parse_options(options)
- flake_checker = FlakesChecker(self.tree, './cookies.txt')
- assert flake_checker.withDoctest is True
-
- def test_doctest_flag_disabled_include_file_exclude_dir(self):
- options = Options(builtins=None, doctests=False,
- include_in_doctest='./cookies.txt',
- exclude_from_doctest='./')
- FlakesChecker.parse_options(options)
- flake_checker = FlakesChecker(self.tree, './cookies.txt')
- assert flake_checker.withDoctest is True
-
- def test_doctest_flag_disabled_include_dir_exclude_file(self):
- options = Options(builtins=None, doctests=False,
- include_in_doctest='./',
- exclude_from_doctest='./cookies.txt')
- FlakesChecker.parse_options(options)
- flake_checker = FlakesChecker(self.tree, './cookies.txt')
- assert flake_checker.withDoctest is False
-
- def test_doctest_flag_disabled_include_file_exclude_file_error(self):
- options = Options(builtins=None, doctests=False,
- include_in_doctest='./cookies.txt',
- exclude_from_doctest='./cookies.txt,cake_yuck.txt')
- self.assertRaises(ValueError, FlakesChecker.parse_options, options)
diff --git a/flake8/tests/test_reporter.py b/flake8/tests/test_reporter.py
deleted file mode 100644
index f91bb52..0000000
--- a/flake8/tests/test_reporter.py
+++ /dev/null
@@ -1,36 +0,0 @@
-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)
diff --git a/flake8/tests/test_util.py b/flake8/tests/test_util.py
deleted file mode 100644
index 221a98e..0000000
--- a/flake8/tests/test_util.py
+++ /dev/null
@@ -1,121 +0,0 @@
-import optparse
-import unittest
-
-from flake8.util import option_normalizer
-
-
-class TestOptionSerializerParsesTrue(unittest.TestCase):
-
- def setUp(self):
- self.option = optparse.Option('--foo', action='store_true')
- self.option_name = 'fake_option'
-
- def test_1_is_true(self):
- value = option_normalizer('1', self.option, self.option_name)
- self.assertTrue(value)
-
- def test_T_is_true(self):
- value = option_normalizer('T', self.option, self.option_name)
- self.assertTrue(value)
-
- def test_TRUE_is_true(self):
- value = option_normalizer('TRUE', self.option, self.option_name)
- self.assertTrue(value, True)
-
- def test_ON_is_true(self):
- value = option_normalizer('ON', self.option, self.option_name)
- self.assertTrue(value)
-
- def test_t_is_true(self):
- value = option_normalizer('t', self.option, self.option_name)
- self.assertTrue(value)
-
- def test_true_is_true(self):
- value = option_normalizer('true', self.option, self.option_name)
- self.assertTrue(value)
-
- def test_on_is_true(self):
- value = option_normalizer('on', self.option, self.option_name)
- self.assertTrue(value)
-
-
-class TestOptionSerializerParsesFalse(unittest.TestCase):
-
- def setUp(self):
- self.option = optparse.Option('--foo', action='store_true')
- self.option_name = 'fake_option'
-
- def test_0_is_false(self):
- value = option_normalizer('0', self.option, self.option_name)
- self.assertFalse(value)
-
- def test_F_is_false(self):
- value = option_normalizer('F', self.option, self.option_name)
- self.assertFalse(value)
-
- def test_FALSE_is_false(self):
- value = option_normalizer('FALSE', self.option, self.option_name)
- self.assertFalse(value)
-
- def test_OFF_is_false(self):
- value = option_normalizer('OFF', self.option, self.option_name)
- self.assertFalse(value)
-
- def test_f_is_false(self):
- value = option_normalizer('f', self.option, self.option_name)
- self.assertFalse(value)
-
- def test_false_is_false(self):
- value = option_normalizer('false', self.option, self.option_name)
- self.assertFalse(value)
-
- def test_off_is_false(self):
- value = option_normalizer('off', self.option, self.option_name)
- self.assertFalse(value)
-
-
-class TestOptionSerializerParsesLists(unittest.TestCase):
-
- def setUp(self):
- self.option = optparse.Option('--select')
- self.option_name = 'select'
- self.answer = ['F401', 'F402', 'F403', 'F404', 'F405']
-
- def test_parses_simple_comma_separated_lists(self):
- value = option_normalizer('F401,F402,F403,F404,F405', self.option,
- self.option_name)
- self.assertEqual(value, self.answer)
-
- def test_parses_less_simple_comma_separated_lists(self):
- value = option_normalizer('F401 ,F402 ,F403 ,F404, F405', self.option,
- self.option_name)
- self.assertEqual(value, self.answer)
-
- value = option_normalizer('F401, F402, F403, F404, F405', self.option,
- self.option_name)
- self.assertEqual(value, self.answer)
-
- def test_parses_comma_separated_lists_with_newlines(self):
- value = option_normalizer('''\
- F401,
- F402,
- F403,
- F404,
- F405,
- ''', self.option, self.option_name)
- self.assertEqual(value, self.answer)
-
-
-class TestOptionSerializerParsesInts(unittest.TestCase):
-
- def setUp(self):
- self.option = optparse.Option('--max-complexity', type='int')
- self.option_name = 'max_complexity'
-
- def test_parses_an_int(self):
- value = option_normalizer('2', self.option, self.option_name)
- self.assertEqual(value, 2)
-
-
-if __name__ == '__main__':
- unittest.main()