Changing our tests so that only the fast ones run by default.
Now you can do: Fast ---- $ python setup.py test $ nosetests $ py.test Slow ---- $ python setup.py test --slow
This commit is contained in:
@@ -8,10 +8,11 @@ import virtualenv
|
||||
import httplib
|
||||
import urllib2
|
||||
import time
|
||||
import pecan
|
||||
|
||||
def has_internet():
|
||||
try:
|
||||
response = urllib2.urlopen('http://74.125.113.99', timeout=1) # Google
|
||||
response = urllib2.urlopen('http://google.com', timeout=1)
|
||||
return True
|
||||
except urllib2.URLError as err: pass # pragma: no cover
|
||||
return False
|
||||
@@ -23,6 +24,11 @@ class TestTemplateBuilds(unittest.TestCase):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@unittest.skipUnless(has_internet(), 'Internet connectivity unavailable.')
|
||||
@unittest.skipUnless(
|
||||
getattr(pecan, '__run_all_tests__', False) is True,
|
||||
'Skipping (really slow). To run, `$ python setup.py test --slow.`'
|
||||
)
|
||||
def setUpClass(cls):
|
||||
# Make a temp install location and record the cwd
|
||||
cls.install_dir = tempfile.mkdtemp()
|
||||
|
||||
20
setup.py
20
setup.py
@@ -1,4 +1,5 @@
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools import setup, command, find_packages
|
||||
from setuptools.command.test import test as TestCommand
|
||||
|
||||
version = '0.1.0'
|
||||
|
||||
@@ -26,6 +27,22 @@ except:
|
||||
|
||||
tests_require = requirements + ['virtualenv']
|
||||
|
||||
|
||||
class test(TestCommand):
|
||||
|
||||
user_options = TestCommand.user_options + [
|
||||
('slow', None, 'Run all tests (even the really slow functional ones)')
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
self.slow = None
|
||||
return TestCommand.initialize_options(self)
|
||||
|
||||
def finalize_options(self):
|
||||
if self.slow:
|
||||
import pecan; setattr(pecan, '__run_all_tests__', True)
|
||||
return TestCommand.finalize_options(self)
|
||||
|
||||
#
|
||||
# call setup
|
||||
#
|
||||
@@ -60,6 +77,7 @@ setup(
|
||||
install_requires = requirements,
|
||||
tests_require = tests_require,
|
||||
test_suite = 'pecan',
|
||||
cmdclass = {'test' : test},
|
||||
entry_points = """
|
||||
[paste.paster_command]
|
||||
pecan-serve = pecan.commands:ServeCommand
|
||||
|
||||
Reference in New Issue
Block a user