summaryrefslogtreecommitdiff
path: root/functional_tests
diff options
context:
space:
mode:
authorTimothée Peignier <timothee.peignier@tryphon.org>2011-12-14 20:10:19 +0100
committerTimothée Peignier <timothee.peignier@tryphon.org>2011-12-14 20:10:19 +0100
commit6347cd149f5f5f9f06ade7d635dc52245fd50124 (patch)
treea04aac5495a6e7fd76f05e9f603bd1eb6a57cb51 /functional_tests
parent79efaa3d4cabff40e0194d2e6680a5070c6476e2 (diff)
downloadnose-6347cd149f5f5f9f06ade7d635dc52245fd50124.tar.gz
remove support for old coverage module and rewrite coverage tests
Diffstat (limited to 'functional_tests')
-rw-r--r--functional_tests/doc_tests/test_coverage_html/coverage_html.rst57
-rw-r--r--functional_tests/doc_tests/test_coverage_html/coverage_html.rst.py3.patch16
-rw-r--r--functional_tests/doc_tests/test_coverage_html/coverage_html_fixtures.py26
-rw-r--r--functional_tests/support/coverage/blah.py (renamed from functional_tests/doc_tests/test_coverage_html/support/blah.py)0
-rw-r--r--functional_tests/support/coverage/tests/test_covered.py (renamed from functional_tests/doc_tests/test_coverage_html/support/tests/test_covered.py)0
-rw-r--r--functional_tests/test_coverage_plugin.py37
6 files changed, 37 insertions, 99 deletions
diff --git a/functional_tests/doc_tests/test_coverage_html/coverage_html.rst b/functional_tests/doc_tests/test_coverage_html/coverage_html.rst
deleted file mode 100644
index 95f9e8a..0000000
--- a/functional_tests/doc_tests/test_coverage_html/coverage_html.rst
+++ /dev/null
@@ -1,57 +0,0 @@
-Generating HTML Coverage with nose
-----------------------------------
-
-.. Note ::
-
- HTML coverage requires Ned Batchelder's `coverage.py`_ module.
-..
-
-Console coverage output is useful but terse. For a more browseable view of
-code coverage, the coverage plugin supports basic HTML coverage output.
-
-.. hide this from the actual documentation:
- >>> from nose.plugins.plugintest import run_buffered as run
- >>> import os
- >>> support = os.path.join(os.path.dirname(__file__), 'support')
- >>> cover_html_dir = os.path.join(support, 'cover')
- >>> cover_file = os.path.join(os.getcwd(), '.coverage')
- >>> if os.path.exists(cover_file):
- ... os.unlink(cover_file)
- ...
-
-
-The console coverage output is printed, as normal.
-
- >>> from nose.plugins.cover import Coverage
- >>> cover_html_dir = os.path.join(support, 'cover')
- >>> run(argv=[__file__, '-v', '--with-coverage', '--cover-package=blah',
- ... '--cover-html', '--cover-html-dir=' + cover_html_dir,
- ... support, ],
- ... plugins=[Coverage()]) # doctest: +REPORT_NDIFF
- test_covered.test_blah ... hi
- ok
- <BLANKLINE>
- Name Stmts Miss Cover Missing
- -------------------------------------
- blah 4 1 75% 6
- ----------------------------------------------------------------------
- Ran 1 test in ...s
- <BLANKLINE>
- OK
-
-The html coverage reports are saved to disk in the directory specified by the
-``--cover-html-dir`` option. In that directory you'll find ``index.html``
-which links to a detailed coverage report for each module in the report. The
-detail pages show the module source, colorized to indicated which lines are
-covered and which are not. There is an example of this HTML output in the
-`coverage.py`_ docs.
-
-.. hide this from the actual documentation:
- >>> os.path.exists(cover_file)
- True
- >>> os.path.exists(os.path.join(cover_html_dir, 'index.html'))
- True
- >>> os.path.exists(os.path.join(cover_html_dir, 'blah.html'))
- True
-
-.. _`coverage.py`: http://nedbatchelder.com/code/coverage/
diff --git a/functional_tests/doc_tests/test_coverage_html/coverage_html.rst.py3.patch b/functional_tests/doc_tests/test_coverage_html/coverage_html.rst.py3.patch
deleted file mode 100644
index f325a01..0000000
--- a/functional_tests/doc_tests/test_coverage_html/coverage_html.rst.py3.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- coverage_html.rst.orig 2010-08-31 23:13:33.000000000 -0700
-+++ coverage_html.rst 2010-08-31 23:14:25.000000000 -0700
-@@ -78,11 +78,11 @@
- </div>
- <div class="coverage">
- <div class="cov"><span class="num"><pre>1</pre></span><pre>def dostuff():</pre></div>
-- <div class="cov"><span class="num"><pre>2</pre></span><pre> print 'hi'</pre></div>
-+ <div class="cov"><span class="num"><pre>2</pre></span><pre> print('hi')</pre></div>
- <div class="skip"><span class="num"><pre>3</pre></span><pre></pre></div>
- <div class="skip"><span class="num"><pre>4</pre></span><pre></pre></div>
- <div class="cov"><span class="num"><pre>5</pre></span><pre>def notcov():</pre></div>
-- <div class="nocov"><span class="num"><pre>6</pre></span><pre> print 'not covered'</pre></div>
-+ <div class="nocov"><span class="num"><pre>6</pre></span><pre> print('not covered')</pre></div>
- <div class="skip"><span class="num"><pre>7</pre></span><pre></pre></div>
- </div>
- </body>
diff --git a/functional_tests/doc_tests/test_coverage_html/coverage_html_fixtures.py b/functional_tests/doc_tests/test_coverage_html/coverage_html_fixtures.py
deleted file mode 100644
index 6829dc2..0000000
--- a/functional_tests/doc_tests/test_coverage_html/coverage_html_fixtures.py
+++ /dev/null
@@ -1,26 +0,0 @@
-import sys
-import os
-import shutil
-from nose.plugins.skip import SkipTest
-from nose.plugins.cover import Coverage
-from nose.plugins.plugintest import munge_nose_output_for_doctest
-
-# This fixture is not reentrant because we have to cleanup the files that
-# coverage produces once all tests have finished running.
-_multiprocess_shared_ = True
-
-def setup_module():
- try:
- import coverage
- if 'active' in Coverage.status:
- raise SkipTest("Coverage plugin is active. Skipping tests of "
- "plugin itself.")
- except ImportError:
- raise SkipTest("coverage module not available")
-
-def teardown_module():
- # Clean up the files produced by coverage
- cover_html_dir = os.path.join(os.path.dirname(__file__), 'support', 'cover')
- if os.path.exists(cover_html_dir):
- shutil.rmtree(cover_html_dir)
-
diff --git a/functional_tests/doc_tests/test_coverage_html/support/blah.py b/functional_tests/support/coverage/blah.py
index ef6657c..ef6657c 100644
--- a/functional_tests/doc_tests/test_coverage_html/support/blah.py
+++ b/functional_tests/support/coverage/blah.py
diff --git a/functional_tests/doc_tests/test_coverage_html/support/tests/test_covered.py b/functional_tests/support/coverage/tests/test_covered.py
index c669c5c..c669c5c 100644
--- a/functional_tests/doc_tests/test_coverage_html/support/tests/test_covered.py
+++ b/functional_tests/support/coverage/tests/test_covered.py
diff --git a/functional_tests/test_coverage_plugin.py b/functional_tests/test_coverage_plugin.py
new file mode 100644
index 0000000..d1b2632
--- /dev/null
+++ b/functional_tests/test_coverage_plugin.py
@@ -0,0 +1,37 @@
+"""Test the coverage plugin."""
+import os
+import unittest
+import shutil
+
+from nose.plugins import PluginTester
+from nose.plugins.cover import Coverage
+
+support = os.path.join(os.path.dirname(__file__), 'support')
+
+
+class TestCoveragePlugin(PluginTester, unittest.TestCase):
+ activate = "--with-coverage"
+ args = ['-v', '--cover-package=blah', '--cover-html']
+ plugins = [Coverage()]
+ suitepath = os.path.join(support, 'coverage')
+
+ def setUp(self):
+ self.cover_file = os.path.join(os.getcwd(), '.coverage')
+ self.cover_html_dir = os.path.join(os.getcwd(), 'cover')
+ if os.path.exists(self.cover_file):
+ os.unlink(self.cover_file)
+ if os.path.exists(self.cover_html_dir):
+ shutil.rmtree(self.cover_html_dir)
+ super(TestCoveragePlugin, self).setUp()
+
+ def runTest(self):
+ self.assertTrue("blah 4 1 75% 6" in self.output)
+ self.assertTrue("Ran 1 test in""" in self.output)
+ # Assert coverage html report exists
+ self.assertTrue(os.path.exists(os.path.join(self.cover_html_dir,
+ 'index.html')))
+ # Assert coverage data is saved
+ self.assertTrue(os.path.exists(self.cover_file))
+
+if __name__ == '__main__':
+ unittest.main()