A handful of improvements:

* Fixing a few broken tests (https://github.com/dreamhost/pecan/issues/28)
* Removing py.test as a package requirement.
* Moving tests *into* the package.
* Adding code to use native unittest discovery (or unittest2 fallback).
This commit is contained in:
Ryan Petrello
2012-03-02 11:58:12 -05:00
parent 06b49fcfd2
commit 7cdf9d3afd
53 changed files with 38 additions and 21 deletions

View File

@@ -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

10
pecan/tests/__init__.py Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -1,7 +1,6 @@
from pecan.deploy import deploy
from unittest import TestCase
import pytest
import os
import sys

View File

@@ -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):

View File

@@ -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

6
tox.ini Normal file
View File

@@ -0,0 +1,6 @@
[tox]
envlist = py26,py27,py31
[testenv]
deps=pytest
commands=py.test