diff --git a/pecan/tests/test_templates.py b/pecan/tests/test_templates.py index 20dddf3..8b99fcf 100644 --- a/pecan/tests/test_templates.py +++ b/pecan/tests/test_templates.py @@ -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() diff --git a/setup.py b/setup.py index fcf03e9..a7d1b27 100644 --- a/setup.py +++ b/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