Skip to content

Commit

Permalink
79 cols, split out str ignores into abs and relative pre-closure-invo…
Browse files Browse the repository at this point in the history
…cation
  • Loading branch information
mcdonc committed Jul 20, 2014
1 parent f0f96d1 commit 53b3402
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions venusian/__init__.py
Expand Up @@ -115,17 +115,19 @@ def onerror(name):
ignore = []

# non-leading-dotted name absolute object name
string_ignores = [ign for ign in ignore if isinstance(ign, str)]
str_ignores = [ign for ign in ignore if isinstance(ign, str)]
# leading dotted name relative to scanned package
relative_ignores = [ign for ign in string_ignores if ign.startswith('.')]
rel_ignores = [ign for ign in str_ignores if ign.startswith('.')]
# non-leading dotted names
abs_ignores = [ign for ign in str_ignores if not ign.startswith('.')]
# functions, e.g. re.compile('pattern').search
callable_ignores = [ign for ign in ignore if callable(ign)]

def _ignore(fullname):
for ign in relative_ignores:
for ign in rel_ignores:
if fullname.startswith(pkg_name + ign):
return True
for ign in string_ignores:
for ign in abs_ignores:
# non-leading-dotted name absolute object name
if fullname.startswith(ign):
return True
Expand Down
10 changes: 10 additions & 0 deletions venusian/tests/test_venusian.py
Expand Up @@ -575,6 +575,16 @@ def test_ignore_mixed_string_and_func(self):
self.assertEqual(test.registrations[1]['ob'], func1)
self.assertEqual(test.registrations[1]['function'], True)

def test_ignore_mixed_string_abs_rel_and_func(self):
import re
from venusian.tests.fixtures import one
test = Test()
scanner = self._makeOne(test=test)
scanner.scan(one, ignore=['venusian.tests.fixtures.one.module2',
'.module',
re.compile('inst').search])
self.assertEqual(len(test.registrations), 0)

def test_lifting1(self):
from venusian.tests.fixtures import lifting1
test = Test()
Expand Down

0 comments on commit 53b3402

Please sign in to comment.