diff --git a/pecan/jsonify.py b/pecan/jsonify.py index 818ce45..6417ae1 100644 --- a/pecan/jsonify.py +++ b/pecan/jsonify.py @@ -5,6 +5,7 @@ except ImportError: # pragma: no cover from datetime import datetime, date from decimal import Decimal + # depending on the version WebOb might have 2 types of dicts try: # WebOb <= 1.1.1 diff --git a/pecan/tests/__init__.py b/pecan/tests/__init__.py new file mode 100644 index 0000000..bb7edf7 --- /dev/null +++ b/pecan/tests/__init__.py @@ -0,0 +1,10 @@ +__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/tests/static/text.txt b/pecan/tests/static/text.txt similarity index 100% rename from tests/static/text.txt rename to pecan/tests/static/text.txt diff --git a/tests/__init__.py b/pecan/tests/templates/__init__.py similarity index 100% rename from tests/__init__.py rename to pecan/tests/templates/__init__.py diff --git a/tests/templates/error_for.html b/pecan/tests/templates/error_for.html similarity index 100% rename from tests/templates/error_for.html rename to pecan/tests/templates/error_for.html diff --git a/tests/templates/form_colors.html b/pecan/tests/templates/form_colors.html similarity index 100% rename from tests/templates/form_colors.html rename to pecan/tests/templates/form_colors.html diff --git a/tests/templates/form_colors_invalid.html b/pecan/tests/templates/form_colors_invalid.html similarity index 100% rename from tests/templates/form_colors_invalid.html rename to pecan/tests/templates/form_colors_invalid.html diff --git a/tests/templates/form_colors_valid.html b/pecan/tests/templates/form_colors_valid.html similarity index 100% rename from tests/templates/form_colors_valid.html rename to pecan/tests/templates/form_colors_valid.html diff --git a/tests/templates/form_login.html b/pecan/tests/templates/form_login.html similarity index 100% rename from tests/templates/form_login.html rename to pecan/tests/templates/form_login.html diff --git a/tests/templates/form_login_invalid.html b/pecan/tests/templates/form_login_invalid.html similarity index 100% rename from tests/templates/form_login_invalid.html rename to pecan/tests/templates/form_login_invalid.html diff --git a/tests/templates/form_login_valid.html b/pecan/tests/templates/form_login_valid.html similarity index 100% rename from tests/templates/form_login_valid.html rename to pecan/tests/templates/form_login_valid.html diff --git a/tests/templates/form_name.html b/pecan/tests/templates/form_name.html similarity index 100% rename from tests/templates/form_name.html rename to pecan/tests/templates/form_name.html diff --git a/tests/templates/form_name_invalid.html b/pecan/tests/templates/form_name_invalid.html similarity index 100% rename from tests/templates/form_name_invalid.html rename to pecan/tests/templates/form_name_invalid.html diff --git a/tests/templates/form_name_invalid_custom.html b/pecan/tests/templates/form_name_invalid_custom.html similarity index 100% rename from tests/templates/form_name_invalid_custom.html rename to pecan/tests/templates/form_name_invalid_custom.html diff --git a/tests/templates/form_name_valid.html b/pecan/tests/templates/form_name_valid.html similarity index 100% rename from tests/templates/form_name_valid.html rename to pecan/tests/templates/form_name_valid.html diff --git a/tests/templates/genshi.html b/pecan/tests/templates/genshi.html similarity index 100% rename from tests/templates/genshi.html rename to pecan/tests/templates/genshi.html diff --git a/tests/templates/genshi_bad.html b/pecan/tests/templates/genshi_bad.html similarity index 100% rename from tests/templates/genshi_bad.html rename to pecan/tests/templates/genshi_bad.html diff --git a/tests/templates/jinja.html b/pecan/tests/templates/jinja.html similarity index 100% rename from tests/templates/jinja.html rename to pecan/tests/templates/jinja.html diff --git a/tests/templates/jinja_bad.html b/pecan/tests/templates/jinja_bad.html similarity index 100% rename from tests/templates/jinja_bad.html rename to pecan/tests/templates/jinja_bad.html diff --git a/tests/templates/kajiki.html b/pecan/tests/templates/kajiki.html similarity index 100% rename from tests/templates/kajiki.html rename to pecan/tests/templates/kajiki.html diff --git a/tests/templates/mako.html b/pecan/tests/templates/mako.html similarity index 100% rename from tests/templates/mako.html rename to pecan/tests/templates/mako.html diff --git a/tests/templates/mako_bad.html b/pecan/tests/templates/mako_bad.html similarity index 100% rename from tests/templates/mako_bad.html rename to pecan/tests/templates/mako_bad.html diff --git a/tests/test_base.py b/pecan/tests/test_base.py similarity index 99% rename from tests/test_base.py rename to pecan/tests/test_base.py index 8517579..772d9f1 100644 --- a/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -602,7 +602,7 @@ class TestBase(TestCase): assert response.status_int == 302 ##should add trailing / and changes location to https assert response.location == 'https://localhost/child/' - assert response.environ['HTTP_X_FORWARDED_PROTO'] == 'https' + assert response.request.environ['HTTP_X_FORWARDED_PROTO'] == 'https' def test_streaming_response(self): import StringIO diff --git a/tests/test_conf.py b/pecan/tests/test_conf.py similarity index 100% rename from tests/test_conf.py rename to pecan/tests/test_conf.py diff --git a/tests/templates/__init__.py b/pecan/tests/test_config/__init__.py similarity index 100% rename from tests/templates/__init__.py rename to pecan/tests/test_config/__init__.py diff --git a/tests/test_config/__init__.py b/pecan/tests/test_config/bad/__init__.py similarity index 100% rename from tests/test_config/__init__.py rename to pecan/tests/test_config/bad/__init__.py diff --git a/tests/test_config/bad/importerror.py b/pecan/tests/test_config/bad/importerror.py similarity index 100% rename from tests/test_config/bad/importerror.py rename to pecan/tests/test_config/bad/importerror.py diff --git a/tests/test_config/bad/module_and_underscore.py b/pecan/tests/test_config/bad/module_and_underscore.py similarity index 100% rename from tests/test_config/bad/module_and_underscore.py rename to pecan/tests/test_config/bad/module_and_underscore.py diff --git a/tests/test_config/bad/syntaxerror.py b/pecan/tests/test_config/bad/syntaxerror.py similarity index 100% rename from tests/test_config/bad/syntaxerror.py rename to pecan/tests/test_config/bad/syntaxerror.py diff --git a/tests/test_config/config.py b/pecan/tests/test_config/config.py similarity index 100% rename from tests/test_config/config.py rename to pecan/tests/test_config/config.py diff --git a/tests/test_config/empty.py b/pecan/tests/test_config/empty.py similarity index 100% rename from tests/test_config/empty.py rename to pecan/tests/test_config/empty.py diff --git a/tests/test_config/forcedict.py b/pecan/tests/test_config/forcedict.py similarity index 100% rename from tests/test_config/forcedict.py rename to pecan/tests/test_config/forcedict.py diff --git a/tests/test_config/bad/__init__.py b/pecan/tests/test_config/sample_apps/sample_app/__init__.py similarity index 100% rename from tests/test_config/bad/__init__.py rename to pecan/tests/test_config/sample_apps/sample_app/__init__.py diff --git a/tests/test_config/sample_apps/sample_app/app.py b/pecan/tests/test_config/sample_apps/sample_app/app.py similarity index 100% rename from tests/test_config/sample_apps/sample_app/app.py rename to pecan/tests/test_config/sample_apps/sample_app/app.py diff --git a/tests/test_config/sample_apps/sample_app_config.py b/pecan/tests/test_config/sample_apps/sample_app_config.py similarity index 100% rename from tests/test_config/sample_apps/sample_app_config.py rename to pecan/tests/test_config/sample_apps/sample_app_config.py diff --git a/tests/test_config/sample_apps/sample_app_config_missing.py b/pecan/tests/test_config/sample_apps/sample_app_config_missing.py similarity index 100% rename from tests/test_config/sample_apps/sample_app_config_missing.py rename to pecan/tests/test_config/sample_apps/sample_app_config_missing.py diff --git a/tests/test_config/sample_apps/sample_app_config_missing_app.py b/pecan/tests/test_config/sample_apps/sample_app_config_missing_app.py similarity index 100% rename from tests/test_config/sample_apps/sample_app_config_missing_app.py rename to pecan/tests/test_config/sample_apps/sample_app_config_missing_app.py diff --git a/tests/test_config/sample_apps/sample_app/__init__.py b/pecan/tests/test_config/sample_apps/sample_app_missing/__init__.py similarity index 100% rename from tests/test_config/sample_apps/sample_app/__init__.py rename to pecan/tests/test_config/sample_apps/sample_app_missing/__init__.py diff --git a/tests/test_config/sample_apps/sample_app_missing/__init__.py b/pecan/tests/test_config/sample_apps/sample_app_missing_app/__init__.py similarity index 100% rename from tests/test_config/sample_apps/sample_app_missing/__init__.py rename to pecan/tests/test_config/sample_apps/sample_app_missing_app/__init__.py diff --git a/tests/test_config/sample_apps/sample_app_missing_app/app.py b/pecan/tests/test_config/sample_apps/sample_app_missing_app/app.py similarity index 100% rename from tests/test_config/sample_apps/sample_app_missing_app/app.py rename to pecan/tests/test_config/sample_apps/sample_app_missing_app/app.py diff --git a/tests/test_deploy.py b/pecan/tests/test_deploy.py similarity index 99% rename from tests/test_deploy.py rename to pecan/tests/test_deploy.py index 342c3f8..da1784b 100644 --- a/tests/test_deploy.py +++ b/pecan/tests/test_deploy.py @@ -1,7 +1,6 @@ from pecan.deploy import deploy from unittest import TestCase -import pytest import os import sys diff --git a/tests/test_generic.py b/pecan/tests/test_generic.py similarity index 100% rename from tests/test_generic.py rename to pecan/tests/test_generic.py diff --git a/tests/test_hooks.py b/pecan/tests/test_hooks.py similarity index 100% rename from tests/test_hooks.py rename to pecan/tests/test_hooks.py diff --git a/tests/test_jsonify.py b/pecan/tests/test_jsonify.py similarity index 95% rename from tests/test_jsonify.py rename to pecan/tests/test_jsonify.py index 54935fa..540a27c 100644 --- a/tests/test_jsonify.py +++ b/pecan/tests/test_jsonify.py @@ -14,7 +14,14 @@ from unittest import TestCase from pecan.jsonify import jsonify, encode, ResultProxy, RowProxy from pecan import Pecan, expose, request from webtest import TestApp -from webob.multidict import MultiDict, UnicodeMultiDict + +# depending on the version WebOb might have 2 types of dicts +try: + # WebOb <= 1.1.1 + from webob.multidict import MultiDict, UnicodeMultiDict +except ImportError: # pragma no cover + # WebOb >= 1.2 + from webob.multidict import MultiDict def make_person(): class Person(object): diff --git a/tests/test_rest.py b/pecan/tests/test_rest.py similarity index 100% rename from tests/test_rest.py rename to pecan/tests/test_rest.py diff --git a/tests/test_secure.py b/pecan/tests/test_secure.py similarity index 100% rename from tests/test_secure.py rename to pecan/tests/test_secure.py diff --git a/tests/test_static.py b/pecan/tests/test_static.py similarity index 100% rename from tests/test_static.py rename to pecan/tests/test_static.py diff --git a/tests/test_templating.py b/pecan/tests/test_templating.py similarity index 100% rename from tests/test_templating.py rename to pecan/tests/test_templating.py diff --git a/tests/test_util.py b/pecan/tests/test_util.py similarity index 100% rename from tests/test_util.py rename to pecan/tests/test_util.py diff --git a/tests/test_validation.py b/pecan/tests/test_validation.py similarity index 100% rename from tests/test_validation.py rename to pecan/tests/test_validation.py diff --git a/setup.py b/setup.py index 4d2c21f..382f6e5 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,7 @@ -from setuptools import setup, Command, find_packages +from setuptools import setup, find_packages version = '0.1.0' -# -# integration with py.test for `python setup.py test` -# -class PyTest(Command): - user_options = [] - def initialize_options(self): - pass - def finalize_options(self): - pass - def run(self): - import py - py.cmdline.pytest(py.std.sys.argv[2:]) - - # # determine requirements # @@ -27,8 +13,7 @@ requirements = [ "Paste >= 1.7.5.1", "PasteScript >= 1.7.3", "formencode >= 1.2.2", - "WebTest >= 1.2.2", - "pytest >= 2.0.3" + "WebTest >= 1.2.2" ] try: @@ -39,6 +24,14 @@ except: except: requirements.append("simplejson >= 2.1.1") +test_suite = 'pecan.tests.collector' +try: + from unittest import TestLoader + assert hasattr(TestLoader, 'discover') + tests_require = [] +except: + tests_require = ['unittest2'] + # # call setup @@ -71,8 +64,9 @@ setup( include_package_data = True, scripts = ['bin/pecan'], zip_safe = False, - cmdclass = {'test': PyTest}, install_requires = requirements, + tests_require = tests_require, + test_suite = test_suite, entry_points = """ [paste.paster_command] pecan-serve = pecan.commands:ServeCommand diff --git a/tests/test_config/sample_apps/sample_app_missing_app/__init__.py b/tests/test_config/sample_apps/sample_app_missing_app/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..0958cc3 --- /dev/null +++ b/tox.ini @@ -0,0 +1,6 @@ +[tox] +envlist = py26,py27,py31 + +[testenv] +deps=pytest +commands=py.test