Skip to content

Commit a794063

Browse files
committed
Merge pull request django-cms#3370 from yakky/feature/generic_static_analysis
Make cms.test_utils.utils.static_analysis usable outside the CMS test su...
2 parents 0326088 + c27f918 commit a794063

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

cms/test_utils/util/static_analysis.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
from pyflakes.checker import Checker
66
from pyflakes.reporter import Reporter
77

8-
import cms
9-
import menus
10-
118

129
def _pyflakes_report_with_nopyflakes(self, messageClass, node, *args, **kwargs):
1310
with open(self.filename, 'r') as code:
@@ -35,7 +32,7 @@ def _check_recursive(paths, reporter):
3532
return num_warnings
3633

3734

38-
def pyflakes():
35+
def pyflakes(packages):
3936
"""
4037
Unfortunately, pyflakes does not have a way to suppress certain errors or
4138
a way to configure the checker class, so we have to monkey patch it.
@@ -46,9 +43,5 @@ def pyflakes():
4643
Checker.__init__ = _pyflakes_no_migrations
4744
Checker.report = _pyflakes_report_with_nopyflakes
4845
reporter = Reporter(sys.stdout, sys.stderr)
49-
paths = [
50-
os.path.abspath(os.path.dirname(cms.__file__)),
51-
os.path.abspath(os.path.dirname(menus.__file__)),
52-
os.path.abspath(__file__),
53-
]
46+
paths = [os.path.dirname(package.__file__) for package in packages]
5447
return _check_recursive(paths, reporter)

cms/tests/static_analysis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ class AboveStaticAnalysisCodeTest(TestCase):
77
Name is pretty lame, but ensure it's executed before every other test
88
"""
99
def test_pyflakes(self):
10-
self.assertEqual(pyflakes(), 0)
10+
import cms
11+
import menus
12+
self.assertEqual(pyflakes((cms, menus)), 0)

0 commit comments

Comments
 (0)