From 65f4f505ab882d947b5b8532d57fef27ce03e8e9 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 7 Mar 2012 18:15:07 -0500 Subject: [PATCH 1/7] Removing the old testing docs (they need to be redone). --- docs/source/quick_start.rst | 5 -- docs/source/testing.rst | 106 +----------------------------------- 2 files changed, 1 insertion(+), 110 deletions(-) diff --git a/docs/source/quick_start.rst b/docs/source/quick_start.rst index 63d2538..5eeadcf 100644 --- a/docs/source/quick_start.rst +++ b/docs/source/quick_start.rst @@ -82,11 +82,6 @@ code here to define tables, ORM definitions, and parse bindings from your configuration file. -.. note:: - The base project contains some ready-to-run tests. Try running - ``py.test`` (the recommended test runner for Pecan) and watch them pass! - - .. _running_application: Running the application diff --git a/docs/source/testing.rst b/docs/source/testing.rst index b085c88..20a13bc 100644 --- a/docs/source/testing.rst +++ b/docs/source/testing.rst @@ -2,108 +2,4 @@ Unit Testing ============= -UnitTesting in Pecan is handled by ``WebTest``. It creates a fake Pecan -application that in turn allows you to make assertions on how those requests -and responses are being handled without starting an HTTP server at all. - - -Tools ------ -Pecan recommends using ``py.test``. It is actually a project requirement when -you install Pecan so you should already have it installed. - - -Structure ---------- -This guide assumes that you have all your tests in a ``tests`` directory. If -you have created a project from the ``base`` project template that Pecan -provides, you should already have this directory with a few tests. - -The template project uses UnitTest-type tests and some of those tests use -WebTest. We will describe how they work in the next section. - -This is how running those tests with ``py.test`` would look like:: - - $ py.test - ============== test session starts ============= - platform darwin -- Python 2.6.1 -- pytest-2.0.1 - collected 11 items - - ./tests/test_config.py ......... - ./tests/test_root.py .. - - ========== 11 passed in 0.30 seconds =========== - - -Configuration and Testing -------------------------- -When you create a new project using the ``base`` project template, Pecan adds -a reference to its ``py.test`` plugin to your project's ``setup.cfg`` file. -This handles loading your Pecan configuration and setting up your app as -defined by your project's ``app.py`` file. - -If you've created your own project without using Pecan's template, you can -load the plugin yourself by adding this to your ``setup.cfg`` file:: - - [pytest] - addopts = -p pecan.testing --with-config=./config.py - -Alternatively, you can just pass those options to ``py.test`` directly. - -By default, Pecan's testing plugin assumes you will be using the ``config.py`` -configuration file to run your tests. To change which configuration file gets -used once, run ``py.test`` with the `--with-config` option. To make the change -permanent, modify that option in the `addopts` setting of your ``setup.cfg`` -file. - -Pecan's ``py.test`` plugin exposes two new variables in the ``py.test`` -namespace: ``temp_dir`` and ``wsgi_app``. - -``py.test.temp_dir`` is a temporary directory that you can use for your tests. -It's created at startup and deleted after all tests have completed. When using -locally distributed testing with py.test, this is guaranteed to be shared by -each test process. This is useful if you need to create some initial resource -(e.g., a database template) that is later copied by each test. If you're using -remotely distributed testing, the directory won't be shared across nodes. - -``py.test.wsgi_app`` is your Pecan app loaded and configured per your project's -``app.py`` file. In your test's ``setUp`` method, you would wrap this with -``TestApp``:: - - from unittest import TestCase - from webtest import TestApp - - import py.test - - class TestRootController(TestCase): - - def setUp(self): - self.app = TestApp(py.test.wsgi_app) - - -Using WebTest with a UnitTest ------------------------------ -Once you have a ``setUp`` method with your ``TestApp`` created, you have a -wealth of actions provided within the test class to interact with your Pecan -application:: - - * POST => self.app.post - * GET => self.app.get - * DELETE => self.app.delete - * PUT => self.app.put - -For example, if you want to assert that you can get to the root of your -application, you could do something similar to this:: - - response = self.app.get('/') - assert response.status_int == 200 - -If you are expecting error responses from your application, make sure to pass -`expect_errors=True`:: - - response = self.app.get('/url/does/not/exist', expect_errors=True) - assert response.status_int == 404 - -If you would like to dig in to more examples in how to test and verify more -actions, take a look at the -`WebTest documentation `_ +TODO From 788ef786e8bfa332af26bb2498eee4fefce4abf0 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 8 Mar 2012 12:42:41 -0500 Subject: [PATCH 2/7] A bunch of work on the default `pecan create` project scaffold: * Simpified the quickstart app. Now it's a simple intro w/ a "documentation" search form. * Updated the quickstart's project to no longer use py.test. * Added some simple illustration tests into the default scaffolded project to illustrate the correct approach for integration and functional tests. --- pecan/configuration.py | 1 + .../project/+package+/controllers/root.py | 16 ++++---- .../project/+package+/templates/index.html | 20 +++------ .../project/+package+/templates/success.html | 13 ------ .../project/+package+/tests/__init__.py | 0 .../project/+package+/tests/__init__.py_tmpl | 18 ++++++++ .../project/+package+/tests/config.py_tmpl | 27 ++++++++++++ .../project/+package+/tests/test_config.py | 41 ------------------- .../project/+package+/tests/test_root.py_tmpl | 8 +--- pecan/templates/project/public/css/style.css | 10 +++-- .../project/public/javascript/shared.js | 0 pecan/templates/project/setup.cfg | 2 - pecan/templates/project/setup.py_tmpl | 1 + 13 files changed, 69 insertions(+), 88 deletions(-) delete mode 100644 pecan/templates/project/+package+/templates/success.html delete mode 100644 pecan/templates/project/+package+/tests/__init__.py create mode 100644 pecan/templates/project/+package+/tests/__init__.py_tmpl create mode 100644 pecan/templates/project/+package+/tests/config.py_tmpl delete mode 100644 pecan/templates/project/+package+/tests/test_config.py delete mode 100644 pecan/templates/project/public/javascript/shared.js delete mode 100644 pecan/templates/project/setup.cfg diff --git a/pecan/configuration.py b/pecan/configuration.py index b2d08f6..4489bb7 100644 --- a/pecan/configuration.py +++ b/pecan/configuration.py @@ -19,6 +19,7 @@ DEFAULT = { 'static_root' : 'public', 'template_path' : '', 'debug' : False, + 'logging' : False, 'force_canonical' : True, 'errors' : { '__force_dict__' : True diff --git a/pecan/templates/project/+package+/controllers/root.py b/pecan/templates/project/+package+/controllers/root.py index f5f61d3..6f031b9 100644 --- a/pecan/templates/project/+package+/controllers/root.py +++ b/pecan/templates/project/+package+/controllers/root.py @@ -1,11 +1,10 @@ -from pecan import expose +from pecan import expose, redirect from formencode import Schema, validators as v from webob.exc import status_map -class SampleForm(Schema): - name = v.String(not_empty=True) - age = v.Int(not_empty=True) +class SearchForm(Schema): + q = v.String(not_empty=True) class RootController(object): @@ -19,13 +18,12 @@ class RootController(object): @index.when( method = 'POST', - template = 'success.html', - schema = SampleForm(), + schema = SearchForm(), error_handler = '/index', - htmlfill = dict(auto_insert_errors = True, prefix_error = False) + htmlfill = dict(auto_insert_errors = True) ) - def index_post(self, name, age): - return dict(name=name) + def index_post(self, q): + redirect('http://pecan.readthedocs.org/en/latest/search.html?q=%s' % q) @expose('error.html') def error(self, status): diff --git a/pecan/templates/project/+package+/templates/index.html b/pecan/templates/project/+package+/templates/index.html index 5385e88..5215546 100644 --- a/pecan/templates/project/+package+/templates/index.html +++ b/pecan/templates/project/+package+/templates/index.html @@ -20,23 +20,15 @@

- To get an idea of how to develop applications with Pecan, - here is a simple form: + ...or you can search the documentation here:

- - - - - - - - - -
- - +
+ + +
+ Enter search terms or a module, class or function name. diff --git a/pecan/templates/project/+package+/templates/success.html b/pecan/templates/project/+package+/templates/success.html deleted file mode 100644 index 938f006..0000000 --- a/pecan/templates/project/+package+/templates/success.html +++ /dev/null @@ -1,13 +0,0 @@ -<%inherit file="layout.html"/> - -## override the title -<%def name="title()"> - Success! - - -## now define the body -
-

-
-

Your form submission was successful! Thanks, ${name}!

-

Go Back

diff --git a/pecan/templates/project/+package+/tests/__init__.py b/pecan/templates/project/+package+/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/templates/project/+package+/tests/__init__.py_tmpl b/pecan/templates/project/+package+/tests/__init__.py_tmpl new file mode 100644 index 0000000..1af16c3 --- /dev/null +++ b/pecan/templates/project/+package+/tests/__init__.py_tmpl @@ -0,0 +1,18 @@ +from unittest import TestCase +from pecan.configuration import set_config +from pecan.testing import load_test_app + +__all__ = ['EnvironmentTest'] + + +class EnvironmentTest(TestCase): + """ + Used for integration or functional tests where you need to test your + literal application of its integration with the framework. + """ + + def setUp(self): + self.app = load_test_app('config.py') + + def tearDown(self): + set_config({}, overwrite=True) diff --git a/pecan/templates/project/+package+/tests/config.py_tmpl b/pecan/templates/project/+package+/tests/config.py_tmpl new file mode 100644 index 0000000..3ef9c49 --- /dev/null +++ b/pecan/templates/project/+package+/tests/config.py_tmpl @@ -0,0 +1,27 @@ +# Server Specific Configurations +server = { + 'port' : '8080', + 'host' : '0.0.0.0' +} + +# Pecan Application Configurations +app = { + 'root' : '${package}.controllers.root.RootController', + 'modules' : ['${package}'], + 'static_root' : '%(confdir)s/public', + 'template_path' : '%(confdir)s/${package}/templates', + 'reload' : True, + 'debug' : True, + 'logging' : False, + 'errors' : { + '404' : '/error/404', + '__force_dict__' : True + } +} + +# Custom Configurations must be in Python dictionary format:: +# +# foo = {'bar':'baz'} +# +# All configurations are accessible at:: +# pecan.conf diff --git a/pecan/templates/project/+package+/tests/test_config.py b/pecan/templates/project/+package+/tests/test_config.py deleted file mode 100644 index b5bcbfd..0000000 --- a/pecan/templates/project/+package+/tests/test_config.py +++ /dev/null @@ -1,41 +0,0 @@ -from unittest import TestCase -import config - - -class TestConfigServer(TestCase): - - def test_server_port(self): - assert config.server['port'] == '8080' - - def test_server_host(self): - assert config.server['host'] == '0.0.0.0' - - -class TestConfigApp(TestCase): - - def test_app_root(self): - root = config.app['root'] - assert root.__class__.__name__ == 'RootController' - - def test_app_modules(self): - assert len(config.app['modules']) == 1 - - def test_app_static_root(self): - assert 'public' in config.app['static_root'] - - def test_app_template_path(self): - assert 'templates' in config.app['template_path'] - - def test_app_reload(self): - assert config.app['reload'] - - def test_app_debug(self): - assert config.app['debug'] - - def test_app_errors(self): - errors = { - '404' : '/error/404', - '__force_dict__' : True - } - - assert config.app['errors'] == errors diff --git a/pecan/templates/project/+package+/tests/test_root.py_tmpl b/pecan/templates/project/+package+/tests/test_root.py_tmpl index 84d38e8..2d08997 100644 --- a/pecan/templates/project/+package+/tests/test_root.py_tmpl +++ b/pecan/templates/project/+package+/tests/test_root.py_tmpl @@ -1,13 +1,9 @@ from unittest import TestCase from webtest import TestApp - -import py.test +from ${package}.tests import EnvironmentTest -class TestRootController(TestCase): - - def setUp(self): - self.app = TestApp(py.test.wsgi_app) +class TestRootController(EnvironmentTest): def test_get(self): response = self.app.get('/') diff --git a/pecan/templates/project/public/css/style.css b/pecan/templates/project/public/css/style.css index 8acc9f7..55c9db5 100644 --- a/pecan/templates/project/public/css/style.css +++ b/pecan/templates/project/public/css/style.css @@ -20,9 +20,13 @@ div#content { } form { - margin: 0 1em; - padding: 1em; - border: 5px transparent; + margin: 0; + padding: 0; + border: 0; +} + +fieldset { + border: 0; } input.error { diff --git a/pecan/templates/project/public/javascript/shared.js b/pecan/templates/project/public/javascript/shared.js deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/templates/project/setup.cfg b/pecan/templates/project/setup.cfg deleted file mode 100644 index aad259c..0000000 --- a/pecan/templates/project/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -addopts = -p pecan.testing --with-config=./config.py diff --git a/pecan/templates/project/setup.py_tmpl b/pecan/templates/project/setup.py_tmpl index 864c61c..6a61f15 100644 --- a/pecan/templates/project/setup.py_tmpl +++ b/pecan/templates/project/setup.py_tmpl @@ -15,6 +15,7 @@ setup( install_requires = [ "pecan", ], + test_suite = '${package}', zip_safe = False, paster_plugins = ${egg_plugins}, include_package_data = True, From 7595b314b480c5970fad4f01648997f796e6735e Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 8 Mar 2012 13:07:58 -0500 Subject: [PATCH 3/7] Removing a ton of unnecessary test fixtures. --- pecan/tests/__init__.py | 10 ---------- pecan/tests/test_config/__init__.py | 0 pecan/tests/test_config/bad/__init__.py | 0 .../test_config/sample_apps/sample_app/__init__.py | 0 pecan/tests/test_config/sample_apps/sample_app/app.py | 3 --- .../tests/test_config/sample_apps/sample_app_config.py | 9 --------- .../sample_apps/sample_app_config_missing.py | 9 --------- .../sample_apps/sample_app_config_missing_app.py | 0 .../sample_apps/sample_app_missing/__init__.py | 0 .../sample_apps/sample_app_missing_app/__init__.py | 0 .../sample_apps/sample_app_missing_app/app.py | 0 setup.py | 3 +-- 12 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 pecan/tests/test_config/__init__.py delete mode 100644 pecan/tests/test_config/bad/__init__.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app/__init__.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app/app.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app_config.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app_config_missing.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app_config_missing_app.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app_missing/__init__.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app_missing_app/__init__.py delete mode 100644 pecan/tests/test_config/sample_apps/sample_app_missing_app/app.py diff --git a/pecan/tests/__init__.py b/pecan/tests/__init__.py index bb7edf7..e69de29 100644 --- a/pecan/tests/__init__.py +++ b/pecan/tests/__init__.py @@ -1,10 +0,0 @@ -__all__ = ['collector'] - -def collector(): - try: - from unittest import TestLoader - assert hasattr(TestLoader, 'discover') - return TestLoader().discover('pecan.tests') - except: - import unittest2 - return unittest2.collector diff --git a/pecan/tests/test_config/__init__.py b/pecan/tests/test_config/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/tests/test_config/bad/__init__.py b/pecan/tests/test_config/bad/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/tests/test_config/sample_apps/sample_app/__init__.py b/pecan/tests/test_config/sample_apps/sample_app/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/tests/test_config/sample_apps/sample_app/app.py b/pecan/tests/test_config/sample_apps/sample_app/app.py deleted file mode 100644 index dcb81fd..0000000 --- a/pecan/tests/test_config/sample_apps/sample_app/app.py +++ /dev/null @@ -1,3 +0,0 @@ -def setup_app(config): - assert config.foo.sample_key == True - return 'DEPLOYED!' diff --git a/pecan/tests/test_config/sample_apps/sample_app_config.py b/pecan/tests/test_config/sample_apps/sample_app_config.py deleted file mode 100644 index 9e01138..0000000 --- a/pecan/tests/test_config/sample_apps/sample_app_config.py +++ /dev/null @@ -1,9 +0,0 @@ -import sample_app - -app = { - 'modules': ['sample_app'] -} - -foo = { - 'sample_key': True -} diff --git a/pecan/tests/test_config/sample_apps/sample_app_config_missing.py b/pecan/tests/test_config/sample_apps/sample_app_config_missing.py deleted file mode 100644 index caf3929..0000000 --- a/pecan/tests/test_config/sample_apps/sample_app_config_missing.py +++ /dev/null @@ -1,9 +0,0 @@ -import sample_app_missing - -app = { - 'modules': ['sample_app_missing'] -} - -foo = { - 'sample_key': True -} diff --git a/pecan/tests/test_config/sample_apps/sample_app_config_missing_app.py b/pecan/tests/test_config/sample_apps/sample_app_config_missing_app.py deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/tests/test_config/sample_apps/sample_app_missing/__init__.py b/pecan/tests/test_config/sample_apps/sample_app_missing/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/tests/test_config/sample_apps/sample_app_missing_app/__init__.py b/pecan/tests/test_config/sample_apps/sample_app_missing_app/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pecan/tests/test_config/sample_apps/sample_app_missing_app/app.py b/pecan/tests/test_config/sample_apps/sample_app_missing_app/app.py deleted file mode 100644 index e69de29..0000000 diff --git a/setup.py b/setup.py index 382f6e5..2e7b671 100644 --- a/setup.py +++ b/setup.py @@ -65,8 +65,7 @@ setup( scripts = ['bin/pecan'], zip_safe = False, install_requires = requirements, - tests_require = tests_require, - test_suite = test_suite, + test_suite = 'pecan', entry_points = """ [paste.paster_command] pecan-serve = pecan.commands:ServeCommand From 76bc3aa3b9d4a0f798ea4b54d21ae53f084e785a Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 8 Mar 2012 13:25:07 -0500 Subject: [PATCH 4/7] Improving the inline documentation for the quickstart tests. --- .../project/+package+/tests/__init__.py_tmpl | 8 ++++---- .../+package+/tests/test_functional.py_tmpl | 19 +++++++++++++++++++ .../project/+package+/tests/test_root.py_tmpl | 14 -------------- .../project/+package+/tests/test_units.py | 7 +++++++ 4 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 pecan/templates/project/+package+/tests/test_functional.py_tmpl delete mode 100644 pecan/templates/project/+package+/tests/test_root.py_tmpl create mode 100644 pecan/templates/project/+package+/tests/test_units.py diff --git a/pecan/templates/project/+package+/tests/__init__.py_tmpl b/pecan/templates/project/+package+/tests/__init__.py_tmpl index 1af16c3..041ddbc 100644 --- a/pecan/templates/project/+package+/tests/__init__.py_tmpl +++ b/pecan/templates/project/+package+/tests/__init__.py_tmpl @@ -2,13 +2,13 @@ from unittest import TestCase from pecan.configuration import set_config from pecan.testing import load_test_app -__all__ = ['EnvironmentTest'] +__all__ = ['FunctionalTest'] -class EnvironmentTest(TestCase): +class FunctionalTest(TestCase): """ - Used for integration or functional tests where you need to test your - literal application of its integration with the framework. + Used functional tests where you need to test your + literal application and its integration with the framework. """ def setUp(self): diff --git a/pecan/templates/project/+package+/tests/test_functional.py_tmpl b/pecan/templates/project/+package+/tests/test_functional.py_tmpl new file mode 100644 index 0000000..be54cc7 --- /dev/null +++ b/pecan/templates/project/+package+/tests/test_functional.py_tmpl @@ -0,0 +1,19 @@ +from unittest import TestCase +from webtest import TestApp +from ${package}.tests import FunctionalTest + + +class TestRootController(FunctionalTest): + + def test_get(self): + response = self.app.get('/') + assert response.status_int == 200 + + def test_search(self): + response = self.app.post('/', params={'q' : 'RestController'}) + assert response.status_int == 302 + assert response.headers['Location'] == 'http://pecan.readthedocs.org/en/latest/search.html?q=RestController' + + def test_get_not_found(self): + response = self.app.get('/a/bogus/url', expect_errors=True) + assert response.status_int == 404 diff --git a/pecan/templates/project/+package+/tests/test_root.py_tmpl b/pecan/templates/project/+package+/tests/test_root.py_tmpl deleted file mode 100644 index 2d08997..0000000 --- a/pecan/templates/project/+package+/tests/test_root.py_tmpl +++ /dev/null @@ -1,14 +0,0 @@ -from unittest import TestCase -from webtest import TestApp -from ${package}.tests import EnvironmentTest - - -class TestRootController(EnvironmentTest): - - def test_get(self): - response = self.app.get('/') - assert response.status_int == 200 - - def test_get_not_found(self): - response = self.app.get('/a/bogus/url', expect_errors=True) - assert response.status_int == 404 diff --git a/pecan/templates/project/+package+/tests/test_units.py b/pecan/templates/project/+package+/tests/test_units.py new file mode 100644 index 0000000..573fb68 --- /dev/null +++ b/pecan/templates/project/+package+/tests/test_units.py @@ -0,0 +1,7 @@ +from unittest import TestCase + + +class TestUnits(TestCase): + + def test_units(self): + assert 5 * 5 == 25 From 7e003ff2b249e6a2f1be3e0c0f52970bfa494668 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 8 Mar 2012 13:33:44 -0500 Subject: [PATCH 5/7] Improving the scaffolding tests to run from any directory. --- pecan/templates/project/+package+/tests/__init__.py_tmpl | 6 +++++- pecan/templates/project/+package+/tests/config.py_tmpl | 4 ++-- pecan/templates/project/setup.cfg_tmpl | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 pecan/templates/project/setup.cfg_tmpl diff --git a/pecan/templates/project/+package+/tests/__init__.py_tmpl b/pecan/templates/project/+package+/tests/__init__.py_tmpl index 041ddbc..1d42690 100644 --- a/pecan/templates/project/+package+/tests/__init__.py_tmpl +++ b/pecan/templates/project/+package+/tests/__init__.py_tmpl @@ -1,3 +1,4 @@ +import os from unittest import TestCase from pecan.configuration import set_config from pecan.testing import load_test_app @@ -12,7 +13,10 @@ class FunctionalTest(TestCase): """ def setUp(self): - self.app = load_test_app('config.py') + self.app = load_test_app(os.path.join( + os.path.dirname(__file__), + 'config.py' + )) def tearDown(self): set_config({}, overwrite=True) diff --git a/pecan/templates/project/+package+/tests/config.py_tmpl b/pecan/templates/project/+package+/tests/config.py_tmpl index 3ef9c49..bb0a688 100644 --- a/pecan/templates/project/+package+/tests/config.py_tmpl +++ b/pecan/templates/project/+package+/tests/config.py_tmpl @@ -8,8 +8,8 @@ server = { app = { 'root' : '${package}.controllers.root.RootController', 'modules' : ['${package}'], - 'static_root' : '%(confdir)s/public', - 'template_path' : '%(confdir)s/${package}/templates', + 'static_root' : '%(confdir)s/../../public', + 'template_path' : '%(confdir)s/../templates', 'reload' : True, 'debug' : True, 'logging' : False, diff --git a/pecan/templates/project/setup.cfg_tmpl b/pecan/templates/project/setup.cfg_tmpl new file mode 100644 index 0000000..111f7cc --- /dev/null +++ b/pecan/templates/project/setup.cfg_tmpl @@ -0,0 +1,6 @@ +[nosetests] +match=^test +where=${package} +nocapture=1 +cover-package=${package} +cover-erase=1 From 378fc9317b9122c8b2cca33f4095cb9510842e08 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 8 Mar 2012 13:43:15 -0500 Subject: [PATCH 6/7] Bringing the scaffolded project's test coverage to 100%. --- pecan/templates/project/+package+/controllers/root.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pecan/templates/project/+package+/controllers/root.py b/pecan/templates/project/+package+/controllers/root.py index 6f031b9..17ea483 100644 --- a/pecan/templates/project/+package+/controllers/root.py +++ b/pecan/templates/project/+package+/controllers/root.py @@ -29,7 +29,7 @@ class RootController(object): def error(self, status): try: status = int(status) - except ValueError: - status = 0 + except ValueError: # pragma: no cover + status = 500 message = getattr(status_map.get(status), 'explanation', '') return dict(status=status, message=message) From 52db816f9f4b274b0dcf2df9df8dddecb9247fa7 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 8 Mar 2012 13:49:44 -0500 Subject: [PATCH 7/7] Fixing a typo. --- pecan/templates/project/+package+/tests/__init__.py_tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pecan/templates/project/+package+/tests/__init__.py_tmpl b/pecan/templates/project/+package+/tests/__init__.py_tmpl index 1d42690..0016a1c 100644 --- a/pecan/templates/project/+package+/tests/__init__.py_tmpl +++ b/pecan/templates/project/+package+/tests/__init__.py_tmpl @@ -8,7 +8,7 @@ __all__ = ['FunctionalTest'] class FunctionalTest(TestCase): """ - Used functional tests where you need to test your + Used for functional tests where you need to test your literal application and its integration with the framework. """