summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTorsten Marek <shlomme@gmail.com>2014-07-26 17:35:38 +0200
committerTorsten Marek <shlomme@gmail.com>2014-07-26 17:35:38 +0200
commit1403ee18cbd1c10fd0be2833c6a69b63f12d3bcb (patch)
treede8fe1cc08fa561d3b6fcb590a70b4166bfd8de6 /test
parentf3a5077d08516bf04d7769f82b44f5bb13da1d74 (diff)
downloadpylint-1403ee18cbd1c10fd0be2833c6a69b63f12d3bcb.tar.gz
Port some regression tests to the new functional test framework and make it possible to specify required packages.
Diffstat (limited to 'test')
-rw-r--r--test/functional/pygtk_enum_crash.args2
-rw-r--r--test/functional/pygtk_enum_crash.py (renamed from test/regrtest_data/pygtk_enum_crash.py)0
-rw-r--r--test/functional/pygtk_import.args2
-rw-r--r--test/functional/pygtk_import.py (renamed from test/regrtest_data/pygtk_import.py)6
-rw-r--r--test/functional/socketerror_import.py (renamed from test/regrtest_data/socketerror_import.py)0
-rw-r--r--test/test_functional.py36
-rw-r--r--test/test_regr.py27
7 files changed, 32 insertions, 41 deletions
diff --git a/test/functional/pygtk_enum_crash.args b/test/functional/pygtk_enum_crash.args
new file mode 100644
index 0000000..7a6c0af
--- /dev/null
+++ b/test/functional/pygtk_enum_crash.args
@@ -0,0 +1,2 @@
+[testoptions]
+requires=gtk
diff --git a/test/regrtest_data/pygtk_enum_crash.py b/test/functional/pygtk_enum_crash.py
index 471afe3..471afe3 100644
--- a/test/regrtest_data/pygtk_enum_crash.py
+++ b/test/functional/pygtk_enum_crash.py
diff --git a/test/functional/pygtk_import.args b/test/functional/pygtk_import.args
new file mode 100644
index 0000000..7a6c0af
--- /dev/null
+++ b/test/functional/pygtk_import.args
@@ -0,0 +1,2 @@
+[testoptions]
+requires=gtk
diff --git a/test/regrtest_data/pygtk_import.py b/test/functional/pygtk_import.py
index 974035e..231885e 100644
--- a/test/regrtest_data/pygtk_import.py
+++ b/test/functional/pygtk_import.py
@@ -1,6 +1,6 @@
-#pylint: disable=R0903,R0904
-"""#10026"""
-__revision__ = 1
+"""Import PyGTK."""
+#pylint: disable=too-few-public-methods,too-many-public-methods
+
from gtk import VBox
import gtk
diff --git a/test/regrtest_data/socketerror_import.py b/test/functional/socketerror_import.py
index 37310cf..37310cf 100644
--- a/test/regrtest_data/socketerror_import.py
+++ b/test/functional/socketerror_import.py
diff --git a/test/test_functional.py b/test/test_functional.py
index 449c933..f8e036d 100644
--- a/test/test_functional.py
+++ b/test/test_functional.py
@@ -54,6 +54,7 @@ class TestFile(object):
_CONVERTERS = {
'min_pyver': parse_python_version,
'max_pyver': parse_python_version,
+ 'requires': lambda s: s.split(',')
}
@@ -63,6 +64,7 @@ class TestFile(object):
self.options = {
'min_pyver': (2, 5),
'max_pyver': (4, 0),
+ 'requires': []
}
self._parse_options()
@@ -180,6 +182,21 @@ class LintModuleTest(testlib.TestCase):
pass
self._test_file = test_file
+ def check_test(self):
+ # change to setUp when not using logilab.testlib any more.
+ if (sys.version_info < self._test_file.options['min_pyver']
+ or sys.version_info >= self._test_file.options['max_pyver']):
+ self.skipTest(
+ 'Test cannot run with Python %s.' % (sys.version.split(' ')[0],))
+ missing = []
+ for req in self._test_file.options['requires']:
+ try:
+ __import__(req)
+ except ImportError:
+ missing.append(req)
+ if missing:
+ self.skipTest('Requires %s to be present.' % (','.join(missing),))
+
def shortDescription(self):
return self._test_file.base
@@ -196,8 +213,9 @@ class LintModuleTest(testlib.TestCase):
used = True
for line in fobj:
parts = line.split(':', 2)
- if len(parts) != 3 and used:
- lines.append(line)
+ if len(parts) != 3:
+ if used:
+ lines.append(line)
else:
linenum = int(parts[1])
if (linenum, parts[0]) in expected:
@@ -220,6 +238,7 @@ class LintModuleTest(testlib.TestCase):
return received, text_result.getvalue()
def runTest(self):
+ self.check_test()
self._linter.check([self._test_file.module])
expected_messages, expected_text = self._get_expected()
@@ -252,10 +271,6 @@ class LintModuleOutputUpdate(LintModuleTest):
fobj.write(received_text)
-def active_in_running_python_version(options):
- return options['min_pyver'] < sys.version_info <= options['max_pyver']
-
-
def suite():
input_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'functional')
@@ -263,11 +278,10 @@ def suite():
for fname in os.listdir(input_dir):
if fname != '__init__.py' and fname.endswith('.py'):
test_file = TestFile(input_dir, fname)
- if active_in_running_python_version(test_file.options):
- if UPDATE:
- suite.addTest(LintModuleOutputUpdate(test_file))
- else:
- suite.addTest(LintModuleTest(test_file))
+ if UPDATE:
+ suite.addTest(LintModuleOutputUpdate(test_file))
+ else:
+ suite.addTest(LintModuleTest(test_file))
return suite
diff --git a/test/test_regr.py b/test/test_regr.py
index 8bc50c2..8d76e2b 100644
--- a/test/test_regr.py
+++ b/test/test_regr.py
@@ -75,28 +75,6 @@ class NonRegrTC(TestCase):
sys.path.pop(0)
os.chdir(cwd)
- def test_gtk_import(self):
- try:
- import gtk
- except ImportError:
- self.skipTest('test skipped: gtk is not available')
- except RuntimeError: # RuntimeError when missing display
- self.skipTest('no display, can\'t run this test')
- linter.check(join(REGR_DATA, 'pygtk_import.py'))
- got = linter.reporter.finalize().strip()
- self.assertEqual(got, '')
-
- def test_gtk_enum_crash(self):
- try:
- import gtk
- except ImportError:
- self.skipTest('test skipped: gtk is not available')
- except RuntimeError: # RuntimeError when missing display
- self.skipTest('no display, can\'t run this test')
- linter.check(join(REGR_DATA, 'pygtk_enum_crash.py'))
- got = linter.reporter.finalize().strip()
- self.assertEqual(got, '')
-
def test_numarray_inference(self):
try:
from numarray import random_array
@@ -115,11 +93,6 @@ class NonRegrTC(TestCase):
got = linter.reporter.finalize().strip()
self.assertEqual(got, '')
- def test_socketerror_import(self):
- linter.check(join(REGR_DATA, 'socketerror_import.py'))
- got = linter.reporter.finalize().strip()
- self.assertEqual(got, '')
-
def test_class__doc__usage(self):
linter.check(join(REGR_DATA, 'classdoc_usage.py'))
got = linter.reporter.finalize().strip()