annotate bitten/build/tests/pythontools.py @ 915:e36f9b446976

Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
author hodgestar
date Mon, 23 May 2011 09:28:19 +0000
parents 7c80375d4817
children
rev   line source
379
0df178e07fdb Use UTF-8 as encoding of source files.
cmlenz
parents: 291
diff changeset
1 # -*- coding: utf-8 -*-
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
2 #
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 379
diff changeset
3 # Copyright (C) 2005-2007 Christopher Lenz <cmlenz@gmx.de>
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
4 # Copyright (C) 2008 Matt Good <matt@matt-good.net>
832
7c80375d4817 Updated copyright to 2010.
osimons
parents: 667
diff changeset
5 # Copyright (C) 2008-2010 Edgewall Software
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 153
diff changeset
6 # All rights reserved.
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
7 #
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 153
diff changeset
8 # This software is licensed as described in the file COPYING, which
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 153
diff changeset
9 # you should have received as part of this distribution. The terms
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 379
diff changeset
10 # are also available at http://bitten.edgewall.org/wiki/License.
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
11
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
12 import os
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
13 import cPickle as pickle
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
14 import shutil
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
15 import tempfile
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
16 import unittest
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
17
221
17e4b8d01db6 * Get rid of `xmlio.SubElement`.
cmlenz
parents: 217
diff changeset
18 from bitten.build import pythontools
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
19 from bitten.build import FileSet
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
20 from bitten.recipe import Context, Recipe
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
21
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
22
464
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
23 class CoverageTestCase(unittest.TestCase):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
24
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
25 def setUp(self):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
26 self.basedir = os.path.realpath(tempfile.mkdtemp())
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
27 self.ctxt = Context(self.basedir)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
28 self.summary = open(os.path.join(self.basedir, 'test-coverage.txt'),
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
29 'w')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
30 self.coverdir = os.path.join(self.basedir, 'coverage')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
31 os.mkdir(self.coverdir)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
32
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
33 def tearDown(self):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
34 shutil.rmtree(self.basedir)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
35
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
36 def _create_file(self, *path):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
37 filename = os.path.join(self.basedir, *path)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
38 dirname = os.path.dirname(filename)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
39 os.makedirs(dirname)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
40 fd = file(filename, 'w')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
41 fd.close()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
42 return filename[len(self.basedir) + 1:]
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
43
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
44 def test_missing_param_summary(self):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
45 self.summary.close()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
46 self.assertRaises(AssertionError, pythontools.coverage, self.ctxt,
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
47 coverdir=self.coverdir)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
48
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
49 def test_empty_summary(self):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
50 self.summary.write("""
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
51 Name Stmts Exec Cover Missing
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
52 -------------------------------------------
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
53 """)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
54 self.summary.close()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
55 pythontools.coverage(self.ctxt, summary=self.summary.name, include='*.py')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
56 type, category, generator, xml = self.ctxt.output.pop()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
57 self.assertEqual(Recipe.REPORT, type)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
58 self.assertEqual('coverage', category)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
59 self.assertEqual(0, len(xml.children))
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
60
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
61 def test_summary_with_absolute_path(self):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
62 self.summary.write("""
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
63 Name Stmts Exec Cover Missing
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
64 -------------------------------------------
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
65 test.module 60 60 100%% %s/test/module.py
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
66 """ % self.ctxt.basedir)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
67 self.summary.close()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
68 self._create_file('test', 'module.py')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
69 pythontools.coverage(self.ctxt, summary=self.summary.name,
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
70 include='test/*')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
71 type, category, generator, xml = self.ctxt.output.pop()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
72 self.assertEqual(Recipe.REPORT, type)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
73 self.assertEqual('coverage', category)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
74 self.assertEqual(1, len(xml.children))
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
75 child = xml.children[0]
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
76 self.assertEqual('coverage', child.name)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
77 self.assertEqual('test.module', child.attr['name'])
498
17ad4028ba14 Reverted incorrect parts of r557 - the `os.path.join` is only needed when the filename passed through is generated by `_create_file`
dfraser
parents: 496
diff changeset
78 self.assertEqual('test/module.py', child.attr['file'])
464
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
79 self.assertEqual(100, child.attr['percentage'])
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
80 self.assertEqual(60, child.attr['lines'])
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
81
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
82 def test_summary_with_relative_path(self):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
83 self.summary.write("""
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
84 Name Stmts Exec Cover Missing
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
85 -------------------------------------------
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
86 test.module 60 60 100% ./test/module.py
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
87 """)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
88 self.summary.close()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
89 self._create_file('test', 'module.py')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
90 pythontools.coverage(self.ctxt, summary=self.summary.name,
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
91 include='test/*')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
92 type, category, generator, xml = self.ctxt.output.pop()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
93 self.assertEqual(Recipe.REPORT, type)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
94 self.assertEqual('coverage', category)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
95 self.assertEqual(1, len(xml.children))
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
96 child = xml.children[0]
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
97 self.assertEqual('coverage', child.name)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
98 self.assertEqual('test.module', child.attr['name'])
498
17ad4028ba14 Reverted incorrect parts of r557 - the `os.path.join` is only needed when the filename passed through is generated by `_create_file`
dfraser
parents: 496
diff changeset
99 self.assertEqual('test/module.py', child.attr['file'])
464
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
100 self.assertEqual(100, child.attr['percentage'])
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
101 self.assertEqual(60, child.attr['lines'])
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
102
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
103 def test_summary_with_missing_lines(self):
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
104 self.summary.write("""
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
105 Name Stmts Exec Cover Missing
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
106 -------------------------------------------
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
107 test.module 28 26 92% 13-14 ./test/module.py
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
108 """)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
109 self.summary.close()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
110 self._create_file('test', 'module.py')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
111 pythontools.coverage(self.ctxt, summary=self.summary.name,
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
112 include='test/*')
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
113 type, category, generator, xml = self.ctxt.output.pop()
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
114 self.assertEqual(Recipe.REPORT, type)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
115 self.assertEqual('coverage', category)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
116 self.assertEqual(1, len(xml.children))
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
117 child = xml.children[0]
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
118 self.assertEqual('coverage', child.name)
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
119 self.assertEqual('test.module', child.attr['name'])
498
17ad4028ba14 Reverted incorrect parts of r557 - the `os.path.join` is only needed when the filename passed through is generated by `_create_file`
dfraser
parents: 496
diff changeset
120 self.assertEqual('test/module.py', child.attr['file'])
464
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
121 self.assertEqual(92, child.attr['percentage'])
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
122 self.assertEqual(28, child.attr['lines'])
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
123
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
124
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
125 class TraceTestCase(unittest.TestCase):
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
126
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
127 def setUp(self):
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
128 self.basedir = os.path.realpath(tempfile.mkdtemp())
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
129 self.ctxt = Context(self.basedir)
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
130 self.summary = open(os.path.join(self.basedir, 'test-coverage.txt'),
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
131 'w')
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
132 self.coverdir = os.path.join(self.basedir, 'coverage')
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
133 os.mkdir(self.coverdir)
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
134
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
135 def tearDown(self):
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
136 shutil.rmtree(self.basedir)
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
137
217
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
138 def _create_file(self, *path):
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
139 filename = os.path.join(self.basedir, *path)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
140 dirname = os.path.dirname(filename)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
141 os.makedirs(dirname)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
142 fd = file(filename, 'w')
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
143 fd.close()
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
144 return filename[len(self.basedir) + 1:]
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
145
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
146 def test_missing_param_summary(self):
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
147 self.summary.close()
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
148 self.assertRaises(AssertionError, pythontools.trace, self.ctxt,
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
149 coverdir='coverage')
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
150
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
151 def test_missing_param_coverdir(self):
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
152 self.summary.close()
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
153 self.assertRaises(AssertionError, pythontools.trace, self.ctxt,
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
154 summary='test-coverage.txt')
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
155
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
156 def test_empty_summary(self):
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
157 self.summary.write('line cov% module (path)')
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
158 self.summary.close()
166
60af98d66f11 * Move the `CommandLine` class from `bitten.util.cmdline` to `bitten.build.api`.
cmlenz
parents: 163
diff changeset
159 pythontools.trace(self.ctxt, summary=self.summary.name, include='*.py',
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
160 coverdir=self.coverdir)
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
161 type, category, generator, xml = self.ctxt.output.pop()
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
162 self.assertEqual(Recipe.REPORT, type)
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
163 self.assertEqual('coverage', category)
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
164 self.assertEqual(0, len(xml.children))
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
165
217
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
166 def test_summary_with_absolute_path(self):
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
167 self.summary.write("""
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
168 lines cov%% module (path)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
169 60 100%% test.module (%s/test/module.py)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
170 """ % self.ctxt.basedir)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
171 self.summary.close()
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
172 self._create_file('test', 'module.py')
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
173 pythontools.trace(self.ctxt, summary=self.summary.name,
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
174 include='test/*', coverdir=self.coverdir)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
175 type, category, generator, xml = self.ctxt.output.pop()
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
176 self.assertEqual(Recipe.REPORT, type)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
177 self.assertEqual('coverage', category)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
178 self.assertEqual(1, len(xml.children))
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
179 child = xml.children[0]
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
180 self.assertEqual('coverage', child.name)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
181 self.assertEqual('test.module', child.attr['name'])
498
17ad4028ba14 Reverted incorrect parts of r557 - the `os.path.join` is only needed when the filename passed through is generated by `_create_file`
dfraser
parents: 496
diff changeset
182 self.assertEqual('test/module.py', child.attr['file'])
217
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
183
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
184 def test_summary_with_relative_path(self):
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
185 self.summary.write("""
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
186 lines cov% module (path)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
187 60 100% test.module (./test/module.py)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
188 """)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
189 self.summary.close()
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
190 self._create_file('test', 'module.py')
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
191 pythontools.trace(self.ctxt, summary=self.summary.name,
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
192 include='test/*', coverdir=self.coverdir)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
193 type, category, generator, xml = self.ctxt.output.pop()
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
194 self.assertEqual(Recipe.REPORT, type)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
195 self.assertEqual('coverage', category)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
196 self.assertEqual(1, len(xml.children))
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
197 child = xml.children[0]
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
198 self.assertEqual('coverage', child.name)
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
199 self.assertEqual('test.module', child.attr['name'])
498
17ad4028ba14 Reverted incorrect parts of r557 - the `os.path.join` is only needed when the filename passed through is generated by `_create_file`
dfraser
parents: 496
diff changeset
200 self.assertEqual('test/module.py', child.attr['file'])
217
44e91849ca43 Handle relative file paths in `trace.py` output. Closes #51.
cmlenz
parents: 203
diff changeset
201
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
202
595
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
203 class PyLintTestCase(unittest.TestCase):
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
204
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
205 def setUp(self):
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
206 self.basedir = os.path.realpath(tempfile.mkdtemp())
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
207 self.ctxt = Context(self.basedir)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
208 self.summary = open(os.path.join(self.basedir, '.lint'), 'w')
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
209
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
210 def tearDown(self):
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
211 shutil.rmtree(self.basedir)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
212
915
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
213 def test_summary_format(self):
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
214 # thoroughly check on report line
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
215 self.summary.write("""
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
216 %s/module/file1.py:42: [C] Missing docstring
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
217 """ % (self.ctxt.basedir,))
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
218 self.summary.close()
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
219 pythontools.pylint(self.ctxt, file_=self.summary.name)
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
220 type, category, generator, xml = self.ctxt.output.pop()
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
221 self.assertEqual(Recipe.REPORT, type)
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
222 self.assertEqual('lint', category)
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
223 self.assertEqual(1, len(xml.children))
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
224 child = xml.children[0]
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
225 self.assertEqual('problem', child.name)
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
226 self.assertEqual('module/file1.py', child.attr['file'])
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
227 self.assertEqual(1, len(child.children))
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
228 msg = child.children[0]
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
229 self.assertEqual('msg', msg.name)
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
230 self.assertEqual(1, len(msg.children))
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
231 self.assertEqual('Missing docstring', msg.children[0])
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
232
595
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
233 def test_summary_with_absolute_path(self):
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
234 # One posix + one windows path to normalize
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
235 self.summary.write("""
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
236 %s/module/file1.py:42: [C] Missing docstring
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
237 %s\\module\\file2.py:42: [C] Missing docstring
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
238 """ % (self.ctxt.basedir, self.ctxt.basedir))
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
239 self.summary.close()
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
240 pythontools.pylint(self.ctxt, file_=self.summary.name)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
241 type, category, generator, xml = self.ctxt.output.pop()
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
242 self.assertEqual(Recipe.REPORT, type)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
243 self.assertEqual('lint', category)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
244 self.assertEqual(2, len(xml.children))
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
245 child = xml.children[0]
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
246 self.assertEqual('problem', child.name)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
247 self.assertEqual('module/file1.py', child.attr['file'])
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
248 child = xml.children[1]
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
249 self.assertEqual('problem', child.name)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
250 self.assertEqual('module/file2.py', child.attr['file'])
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
251
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
252 def test_summary_with_relative_path(self):
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
253 # One posix + one windows path to normalize
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
254 self.summary.write("""
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
255 module/file1.py:42: [C] Missing docstring
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
256 module\\file2.py:42: [C] Missing docstring
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
257 """)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
258 self.summary.close()
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
259 pythontools.pylint(self.ctxt, file_=self.summary.name)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
260 type, category, generator, xml = self.ctxt.output.pop()
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
261 self.assertEqual(Recipe.REPORT, type)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
262 self.assertEqual('lint', category)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
263 self.assertEqual(2, len(xml.children))
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
264 child = xml.children[0]
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
265 self.assertEqual('problem', child.name)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
266 self.assertEqual('module/file1.py', child.attr['file'])
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
267 child = xml.children[1]
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
268 self.assertEqual('problem', child.name)
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
269 self.assertEqual('module/file2.py', child.attr['file'])
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
270
915
e36f9b446976 Wrap lint report messages in a msg tag (includes a test and a documentation update). Fixes #547.
hodgestar
parents: 832
diff changeset
271
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
272 class FigleafTestCase(unittest.TestCase):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
273
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
274 def setUp(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
275 self.basedir = os.path.realpath(tempfile.mkdtemp())
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
276 self.ctxt = Context(self.basedir)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
277 self.summary = open(os.path.join(self.basedir, '.figleaf'), 'w')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
278
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
279 def tearDown(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
280 shutil.rmtree(self.basedir)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
281
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
282 def _create_file(self, *path):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
283 filename = os.path.join(self.basedir, *path)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
284 dirname = os.path.dirname(filename)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
285 os.makedirs(dirname)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
286 fd = file(filename, 'w')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
287 fd.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
288 return filename[len(self.basedir) + 1:]
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
289
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
290 def test_missing_param_summary(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
291 self.summary.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
292 self.assertRaises(AssertionError, pythontools.coverage, self.ctxt)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
293
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
294 def test_empty_summary(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
295 pickle.dump({}, self.summary)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
296 self.summary.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
297 pythontools.figleaf(self.ctxt, summary=self.summary.name, include='*.py')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
298 type, category, generator, xml = self.ctxt.output.pop()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
299 self.assertEqual(Recipe.REPORT, type)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
300 self.assertEqual('coverage', category)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
301 self.assertEqual(0, len(xml.children))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
302
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
303 def test_missing_coverage_file(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
304 self.summary.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
305 pythontools.figleaf(self.ctxt, summary='non-existant-file', include='*.py')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
306 self.assertEqual([], self.ctxt.output)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
307
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
308 def test_summary_with_absolute_path(self):
500
6a9268d10d09 Port of [566] to trunk.
wbell
parents: 498
diff changeset
309 filename = os.sep.join([self.ctxt.basedir, 'test', 'module.py'])
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
310 pickle.dump({
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
311 filename: set([1, 4, 5]),
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
312 }, self.summary)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
313 self.summary.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
314 sourcefile = self.ctxt.resolve(self._create_file('test', 'module.py'))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
315 open(sourcefile, 'w').write(
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
316 "if foo: # line 1\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
317 " print 'uncovered' # line 2\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
318 "else: # line 3 (uninteresting)\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
319 " print 'covered' # line 4\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
320 "print 'covered' # line 6\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
321 )
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
322 pythontools.figleaf(self.ctxt, summary=self.summary.name,
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
323 include='test/*')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
324 type, category, generator, xml = self.ctxt.output.pop()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
325 self.assertEqual(Recipe.REPORT, type)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
326 self.assertEqual('coverage', category)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
327 self.assertEqual(1, len(xml.children))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
328 child = xml.children[0]
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
329 self.assertEqual('coverage', child.name)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
330 self.assertEqual('test.module', child.attr['name'])
667
9d19ae17a401 0.6dev: Follow-up to [740] - fix incorrect tests.
osimons
parents: 595
diff changeset
331 self.assertEqual('test/module.py', child.attr['file'])
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
332 self.assertEqual(75, child.attr['percentage'])
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
333 self.assertEqual(4, child.attr['lines'])
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
334 self.assertEqual('1 0 - 1 1', child.attr['line_hits'])
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
335
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
336 def test_summary_with_non_covered_file(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
337 pickle.dump({}, self.summary)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
338 self.summary.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
339 sourcefile = self.ctxt.resolve(self._create_file('test', 'module.py'))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
340 open(sourcefile, 'w').write(
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
341 "print 'line 1'\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
342 "print 'line 2'\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
343 "print 'line 3'\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
344 "print 'line 4'\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
345 "print 'line 5'\n"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
346 )
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
347 pythontools.figleaf(self.ctxt, summary=self.summary.name,
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
348 include='test/*')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
349 type, category, generator, xml = self.ctxt.output.pop()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
350 self.assertEqual(Recipe.REPORT, type)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
351 self.assertEqual('coverage', category)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
352 self.assertEqual(1, len(xml.children))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
353 child = xml.children[0]
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
354 self.assertEqual('coverage', child.name)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
355 self.assertEqual('test.module', child.attr['name'])
667
9d19ae17a401 0.6dev: Follow-up to [740] - fix incorrect tests.
osimons
parents: 595
diff changeset
356 self.assertEqual('test/module.py', child.attr['file'])
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
357 self.assertEqual(0, child.attr['percentage'])
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
358 self.assertEqual(5, child.attr['lines'])
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
359
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
360 def test_summary_with_non_python_files(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
361 "Figleaf coverage reports should not include files that do not end in .py"
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
362 pickle.dump({}, self.summary)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
363 self.summary.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
364 sourcefile = self.ctxt.resolve(self._create_file('test', 'document.txt'))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
365 open(sourcefile, 'w').write("\n")
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
366 pythontools.figleaf(self.ctxt, summary=self.summary.name,
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
367 include='test/*')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
368 type, category, generator, xml = self.ctxt.output.pop()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
369 self.assertEqual(Recipe.REPORT, type)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
370 self.assertEqual('coverage', category)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
371 self.assertEqual(0, len(xml.children))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
372
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
373
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
374 class FilenameNormalizationTestCase(unittest.TestCase):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
375
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
376 def setUp(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
377 self.basedir = os.path.realpath(tempfile.mkdtemp())
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
378 self.ctxt = Context(self.basedir)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
379
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
380 def tearDown(self):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
381 shutil.rmtree(self.basedir)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
382
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
383 def _create_file(self, *path):
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
384 filename = os.path.join(self.basedir, *path)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
385 dirname = os.path.dirname(filename)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
386 os.makedirs(dirname)
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
387 fd = file(filename, 'w')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
388 fd.close()
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
389 return filename[len(self.basedir) + 1:]
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
390
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
391 def test_absolute_path(self):
500
6a9268d10d09 Port of [566] to trunk.
wbell
parents: 498
diff changeset
392 filename = os.sep.join([self.ctxt.basedir, 'test', 'module.py'])
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
393 self._create_file('test', 'module.py')
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
394 filenames = pythontools._normalize_filenames(
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
395 self.ctxt, [filename],
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
396 FileSet(self.ctxt.basedir, '**/*.py', None))
498
17ad4028ba14 Reverted incorrect parts of r557 - the `os.path.join` is only needed when the filename passed through is generated by `_create_file`
dfraser
parents: 496
diff changeset
397 self.assertEqual(['test/module.py'], list(filenames))
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
398
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
399
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
400 class UnittestTestCase(unittest.TestCase):
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
401
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
402 def setUp(self):
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
403 self.basedir = os.path.realpath(tempfile.mkdtemp())
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
404 self.ctxt = Context(self.basedir)
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
405 self.results_xml = open(os.path.join(self.basedir, 'test-results.xml'),
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
406 'w')
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
407
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
408 def tearDown(self):
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
409 shutil.rmtree(self.basedir)
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
410
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
411 def test_missing_file_param(self):
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 133
diff changeset
412 self.results_xml.close()
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
413 self.assertRaises(AssertionError, pythontools.unittest, self.ctxt)
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
414
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
415 def test_empty_results(self):
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
416 self.results_xml.write('<?xml version="1.0"?>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
417 '<unittest-results>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
418 '</unittest-results>')
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
419 self.results_xml.close()
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
420 pythontools.unittest(self.ctxt, self.results_xml.name)
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
421 type, category, generator, xml = self.ctxt.output.pop()
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
422 self.assertEqual(Recipe.REPORT, type)
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
423 self.assertEqual('test', category)
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
424 self.assertEqual(0, len(xml.children))
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
425
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
426 def test_successful_test(self):
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
427 self.results_xml.write('<?xml version="1.0"?>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
428 '<unittest-results>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
429 '<test duration="0.12" status="success"'
133
07505cab4ba6 Fix unit test for {{{<python:unittest>}}} recipe command.
cmlenz
parents: 132
diff changeset
430 ' file="%s"'
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
431 ' name="test_foo (pkg.BarTestCase)"/>'
133
07505cab4ba6 Fix unit test for {{{<python:unittest>}}} recipe command.
cmlenz
parents: 132
diff changeset
432 '</unittest-results>'
07505cab4ba6 Fix unit test for {{{<python:unittest>}}} recipe command.
cmlenz
parents: 132
diff changeset
433 % os.path.join(self.ctxt.basedir, 'bar_test.py'))
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
434 self.results_xml.close()
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
435 pythontools.unittest(self.ctxt, self.results_xml.name)
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
436 type, category, generator, xml = self.ctxt.output.pop()
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
437 self.assertEqual(1, len(xml.children))
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
438 test_elem = xml.children[0]
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
439 self.assertEqual('test', test_elem.name)
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
440 self.assertEqual('0.12', test_elem.attr['duration'])
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
441 self.assertEqual('success', test_elem.attr['status'])
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
442 self.assertEqual('bar_test.py', test_elem.attr['file'])
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
443 self.assertEqual('test_foo (pkg.BarTestCase)', test_elem.attr['name'])
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
444
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
445 def test_file_path_normalization(self):
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
446 self.results_xml.write('<?xml version="1.0"?>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
447 '<unittest-results>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
448 '<test duration="0.12" status="success"'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
449 ' file="%s"'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
450 ' name="test_foo (pkg.BarTestCase)"/>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
451 '</unittest-results>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
452 % os.path.join(self.ctxt.basedir, 'bar_test.py'))
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
453 self.results_xml.close()
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
454 pythontools.unittest(self.ctxt, self.results_xml.name)
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
455 type, category, generator, xml = self.ctxt.output.pop()
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
456 self.assertEqual(1, len(xml.children))
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
457 self.assertEqual('bar_test.py', xml.children[0].attr['file'])
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
458
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
459 def test_missing_file_attribute(self):
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
460 self.results_xml.write('<?xml version="1.0"?>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
461 '<unittest-results>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
462 '<test duration="0.12" status="success"'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
463 ' name="test_foo (pkg.BarTestCase)"/>'
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
464 '</unittest-results>')
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
465 self.results_xml.close()
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
466 pythontools.unittest(self.ctxt, self.results_xml.name)
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
467 type, category, generator, xml = self.ctxt.output.pop()
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 166
diff changeset
468 self.assertEqual(1, len(xml.children))
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
469 self.assertEqual(None, xml.children[0].attr.get('file'))
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
470
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
471
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
472 def suite():
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
473 suite = unittest.TestSuite()
464
894b0b0721da add line counts for coverage.py and some initial unit tests
mgood
parents: 408
diff changeset
474 suite.addTest(unittest.makeSuite(CoverageTestCase, 'test'))
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
475 suite.addTest(unittest.makeSuite(TraceTestCase, 'test'))
595
538e4f975505 0.6dev: Fix for filenames in pylint report that made incorrect absolute pathnames. Filenames should now be properly shortened, and link correctly to source browser from lint report.
osimons
parents: 500
diff changeset
476 suite.addTest(unittest.makeSuite(PyLintTestCase, 'test'))
482
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
477 suite.addTest(unittest.makeSuite(FigleafTestCase, 'test'))
b87eda443ffc add figleaf coverage support
mgood
parents: 464
diff changeset
478 suite.addTest(unittest.makeSuite(FilenameNormalizationTestCase, 'test'))
125
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
479 suite.addTest(unittest.makeSuite(UnittestTestCase, 'test'))
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
480 return suite
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
481
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
482 if __name__ == '__main__':
92e29e6b4c16 * The {{{python:trace>}}} recipe command now transmits coverage statistics to the build master. Closes #33.
cmlenz
parents:
diff changeset
483 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software