summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-03-17 14:55:57 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-03-17 14:55:57 -0500
commit48b995fa62004e0595b4de9edb93f3ea2677a397 (patch)
tree1b2443d960d68eb10bd4e14b83be8f01115ab717
parent3da9fd3cb734f5d5a528036e3eb4f8e5e14fe63c (diff)
downloadflake8-48b995fa62004e0595b4de9edb93f3ea2677a397.tar.gz
Remove unnecessary and outdated test runner
-rw-r--r--flake8/processor.py6
-rwxr-xr-xrun_tests.py32
-rw-r--r--tests/unit/test_file_processor.py29
3 files changed, 22 insertions, 45 deletions
diff --git a/flake8/processor.py b/flake8/processor.py
index 1dc27a1..bcb33cc 100644
--- a/flake8/processor.py
+++ b/flake8/processor.py
@@ -46,14 +46,16 @@ class FileProcessor(object):
NOQA_FILE = re.compile(r'\s*# flake8[:=]\s*noqa', re.I)
- def __init__(self, filename, options):
+ def __init__(self, filename, options, lines=None):
"""Initialice our file processor.
:param str filename:
Name of the file to process
"""
self.filename = filename
- self.lines = self.read_lines()
+ self.lines = lines
+ if lines is None:
+ self.lines = self.read_lines()
self.strip_utf_bom()
self.options = options
diff --git a/run_tests.py b/run_tests.py
deleted file mode 100755
index 09d6884..0000000
--- a/run_tests.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-
-import unittest
-import os
-import re
-import sys
-sys.path.insert(0, '.')
-
-TEST_DIR = 'flake8.tests'
-
-
-def collect_tests():
- # list files in directory tests/
- names = os.listdir(TEST_DIR.replace('.', '/'))
- regex = re.compile("(?!_+)\w+\.py$")
- join = '.'.join
- # Make a list of the names like 'tests.test_name'
- names = [join([TEST_DIR, f[:-3]]) for f in names if regex.match(f)]
- modules = [__import__(name, fromlist=[TEST_DIR]) for name in names]
- load_tests = unittest.defaultTestLoader.loadTestsFromModule
- suites = [load_tests(m) for m in modules]
- suite = suites.pop()
- for s in suites:
- suite.addTests(s)
- return suite
-
-if __name__ == "__main__":
- suite = collect_tests()
- res = unittest.TextTestRunner(verbosity=1).run(suite)
-
- # If it was successful, we don't want to exit with code 1
- raise SystemExit(not res.wasSuccessful())
diff --git a/tests/unit/test_file_processor.py b/tests/unit/test_file_processor.py
index e26bc83..2970697 100644
--- a/tests/unit/test_file_processor.py
+++ b/tests/unit/test_file_processor.py
@@ -1,26 +1,33 @@
-"""Tests for the FileChecker class."""
-from flake8 import checker
+"""Tests for the FileProcessor class."""
+import optparse
+
+from flake8 import processor
import pytest
+def options_from(**kwargs):
+ kwargs.setdefault('hang_closing', True)
+ kwargs.setdefault('max_line_length', 79)
+ kwargs.setdefault('verbose', False)
+ return optparse.Values(kwargs)
+
+
def test_read_lines_splits_lines():
"""Verify that read_lines splits the lines of the file."""
- file_checker = checker.FileChecker(__file__, [])
- lines = file_checker.read_lines()
+ file_processor = processor.FileProcessor(__file__, options_from())
+ lines = file_processor.lines
assert len(lines) > 5
- assert '"""Tests for the FileChecker class."""\n' in lines
+ assert '"""Tests for the FileProcessor class."""\n' in lines
@pytest.mark.parametrize('first_line', [
'\xEF\xBB\xBF"""Module docstring."""\n',
- '\uFEFF"""Module docstring."""\n',
+ u'\uFEFF"""Module docstring."""\n',
])
def test_strip_utf_bom(first_line):
r"""Verify that we strip '\xEF\xBB\xBF' from the first line."""
lines = [first_line]
- file_checker = checker.FileChecker('stdin', [])
- file_checker.lines = lines[:]
- file_checker.strip_utf_bom()
- assert file_checker.lines != lines
- assert file_checker.lines[0] == '"""Module docstring."""\n'
+ file_processor = processor.FileProcessor('-', options_from(), lines[:])
+ assert file_processor.lines != lines
+ assert file_processor.lines[0] == '"""Module docstring."""\n'