summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamian Johnson <atagar@torproject.org>2016-11-06 11:47:14 -0800
committerDamian Johnson <atagar@torproject.org>2016-11-06 11:47:14 -0800
commit058fb76c9ba57676df3c209dfed6996ffb565257 (patch)
treebd67e85842db331f7ada64bfa3b6e634ac4c15ed
parentf76f70b55d17a6062f48ea732d38f15bf2dfa713 (diff)
Suppress pyflakes issues by prefix or suffix
On #17306 neel's test output has quite a few pyflakes issues I don't get... https://trac.torproject.org/projects/tor/attachment/ticket/17306/integ_test.txt These would be a hassle to suppress one by one so allowing our config to suppress by prefix or suffix.
-rw-r--r--docs/change_log.rst1
-rwxr-xr-xrun_tests.py2
-rw-r--r--stem/util/test_tools.py21
-rw-r--r--test/settings.cfg5
4 files changed, 25 insertions, 4 deletions
diff --git a/docs/change_log.rst b/docs/change_log.rst
index 0d8dcf28..ba496a7c 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -91,6 +91,7 @@ The following are only available within Stem's `git repository
* The 'ss' connection resolver didn't work on Gentoo (:trac:`18079`)
* Recognize IPv4-mapped IPv6 addresses in our utils (:trac:`18079`)
* Allow :func:`stem.util.conf.Config.set` to remove values when provided with a **None** value
+ * Support prefix and suffix issue strings in :func:`~stem.util.test_tools.pyflakes_issues`
* Additional information when :func:`~stem.util.system.call` fails through a :class:`~stem.util.system.CallError`
* Added **stem.util.system.SYSTEM_CALL_TIME** with the total time spent on system calls
* Added an **is_ipv6** value to :class:`~stem.util.connection.Connection` instances
diff --git a/run_tests.py b/run_tests.py
index abe77e4a..db34e5b4 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -125,7 +125,7 @@ def main():
if not stem.prereq.is_mock_available():
try:
try:
- import unittest.mock
+ import unittest.mock as mock
except ImportError:
import mock
diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index a09f7352..406ebd75 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -273,7 +273,8 @@ def pyflakes_issues(paths):
pyflakes.ignore stem/util/test_tools.py => 'pycodestyle' imported but unused
If a 'exclude_paths' was set in our test config then we exclude any absolute
- paths matching those regexes.
+ paths matching those regexes. Issue strings can start or end with an asterisk
+ to match just against the prefix or suffix.
.. versionchanged:: 1.3.0
Renamed from get_pyflakes_issues() to pyflakes_issues(). The old name
@@ -283,6 +284,9 @@ def pyflakes_issues(paths):
Changing tuples in return value to be namedtuple instances, and adding the
line that had the issue.
+ .. versionchanged:: 1.5.0
+ Support matching against prefix or suffix issue strings.
+
:param list paths: paths to search for problems
:returns: dict of paths list of :class:`stem.util.test_tools.Issue` instances
@@ -316,8 +320,19 @@ def pyflakes_issues(paths):
# path ends with any of them.
for ignored_path, ignored_issues in self._ignored_issues.items():
- if path.endswith(ignored_path) and issue in ignored_issues:
- return True
+ if path.endswith(ignored_path):
+ is_match = issue in ignored_issues
+
+ for prefix in [i[:1] for i in ignored_issues if i.endswith('*')]:
+ if issue.startswith(prefix):
+ is_match = True
+
+ for suffix in [i[1:] for i in ignored_issues if i.startswith('*')]:
+ if issue.endswith(suffix):
+ is_match = True
+
+ if is_match:
+ return True
return False
diff --git a/test/settings.cfg b/test/settings.cfg
index 9504da36..49132029 100644
--- a/test/settings.cfg
+++ b/test/settings.cfg
@@ -144,9 +144,13 @@ pyflakes.ignore stem/__init__.py => undefined name 'long'
pyflakes.ignore stem/__init__.py => undefined name 'unicode'
pyflakes.ignore stem/control.py => undefined name 'controller'
pyflakes.ignore stem/manual.py => undefined name 'unichr'
+pyflakes.ignore stem/prereq.py => 'Crypto.PublicKey.RSA' imported but unused
+pyflakes.ignore stem/prereq.py => 'Crypto.Util.asn1' imported but unused
+pyflakes.ignore stem/prereq.py => 'Crypto.Util.number.long_to_bytes' imported but unused
pyflakes.ignore stem/prereq.py => 'RSA' imported but unused
pyflakes.ignore stem/prereq.py => 'asn1' imported but unused
pyflakes.ignore stem/prereq.py => 'unittest' imported but unused
+pyflakes.ignore stem/prereq.py => 'unittest.mock' imported but unused
pyflakes.ignore stem/prereq.py => 'long_to_bytes' imported but unused
pyflakes.ignore stem/interpreter/__init__.py => undefined name 'raw_input'
pyflakes.ignore stem/util/conf.py => undefined name 'unicode'
@@ -154,6 +158,7 @@ pyflakes.ignore stem/util/test_tools.py => 'pyflakes' imported but unused
pyflakes.ignore stem/util/test_tools.py => 'pycodestyle' imported but unused
pyflakes.ignore test/mocking.py => undefined name 'test'
pyflakes.ignore test/unit/response/events.py => 'from stem import *' used; unable to detect undefined names
+pyflakes.ignore test/unit/response/events.py => *may be undefined, or defined from star imports: stem
# Test modules we want to run. Modules are roughly ordered by the dependencies
# so the lowest level tests come first. This is because a problem in say,