Merge lp:~mandel/ubuntuone-dev-tools/allow_ignore_modules into lp:ubuntuone-dev-tools

Proposed by Manuel de la Peña on 2010-12-20
Status: Merged
Approved by: Manuel de la Peña on 2010-12-20
Approved revision: 16
Merged at revision: 15
Proposed branch: lp:~mandel/ubuntuone-dev-tools/allow_ignore_modules
Merge into: lp:ubuntuone-dev-tools
Diff against target: 54 lines (+13/-4)
1 file modified
bin/u1trial (+13/-4)
To merge this branch: bzr merge lp:~mandel/ubuntuone-dev-tools/allow_ignore_modules
Reviewer Review Type Date Requested Status
Natalia Bidart Approve on 2010-12-20
dobey (community) 2010-12-20 Approve on 2010-12-20
Review via email: mp+44218@code.launchpad.net

Commit Message

Added extra commnad line option to ignore test modules from the test run to fix lp:692516

Description of the Change

Added extra commnad line option to ignore test modules from the test run to fix lp:692516

To post a comment you must log in.
dobey (dobey) :
review: Approve
Natalia Bidart (nataliabidart) wrote :

ignored = [n.strip() for n in ignored.split(',')]

 should be

ignored = map(str.strip, ignored.split(','))

Also, "not test in ignored" is best read as "test not in ignored".
Please fix those before land.

review: Approve
16. By Manuel de la Peña on 2010-12-20

Make code more pythonic.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1trial'
2--- bin/u1trial 2010-12-13 20:32:49 +0000
3+++ bin/u1trial 2010-12-20 15:36:55 +0000
4@@ -89,13 +89,19 @@
5 else:
6 return unittest.defaultTestLoader.loadTestsFromModule(module)
7
8- def _collect_tests(self, path, test_pattern):
9+ def _collect_tests(self, path, test_pattern, ignored):
10 """Return the set of unittests."""
11 suite = unittest.TestSuite()
12 if test_pattern:
13 pattern = re.compile('.*%s.*' % test_pattern)
14 else:
15 pattern = None
16+
17+ # get the ignored modules/tests
18+ if ignored:
19+ ignored = map(str.strip, ignored.split(','))
20+ else:
21+ ignored = []
22
23 # Disable this lint warning as we need to access _tests in the
24 # test suites, to collect the tests
25@@ -122,7 +128,7 @@
26 for root, dirs, files in os.walk(path):
27 for test in files:
28 filepath = os.path.join(root, test)
29- if test.endswith(".py"):
30+ if test.endswith(".py") and test not in ignored:
31 self.source_files.append(filepath)
32 if test.startswith("test_"):
33 module_suite = self._load_unittest(filepath)
34@@ -145,7 +151,7 @@
35 coverage.start()
36
37 try:
38- suite = self._collect_tests(path, options.test)
39+ suite = self._collect_tests(path, options.test, options.ignored)
40 if options.loops:
41 old_suite = suite
42 suite = unittest.TestSuite()
43@@ -188,7 +194,10 @@
44 metavar="LOOPS")
45 parser.add_option("-c", "--coverage", action="store_true", dest="coverage",
46 help="print a coverage report when finished")
47-
48+ parser.add_option("-i", "--ignored-modules", dest="ignored", default=None,
49+ help="comma separated test moodules to ignore, "
50+ + " e.g: test_gtk.py, test_account.py")
51+
52 (options, args) = parser.parse_args()
53 if args:
54 testpath = args[0]

Subscribers

People subscribed via source and target branches

to all changes: