From bad02d68e90e887f86bbeb866a45bfdcd5a3b984 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 9 Dec 2009 23:11:17 +0000 Subject: - A new dependency on the ``twill`` package was added to the ``setup.py`` ``tests_require`` argument (Twill will only be downloaded when :mod:`repoze.bfg` ``setup.py test`` or ``setup.py nosetests`` is invoked). --- CHANGES.txt | 9 +++++++ repoze/bfg/tests/fixtureapp/another.zcml | 2 -- repoze/bfg/tests/fixtureapp/configure.zcml | 4 --- repoze/bfg/tests/fixtureapp/views.py | 5 ++++ repoze/bfg/tests/test_integration.py | 42 +++++++++++++++++++++--------- setup.py | 3 ++- 6 files changed, 46 insertions(+), 19 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7789241d4..f9ee7d81a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -22,6 +22,15 @@ Documentation - Added "Thread Locals" narrative chapter to documentation, and added a API chapter documenting the ``repoze.bfg.threadlocals`` module. +Dependencies +------------ + +- A new dependency on the ``twill`` package was added to the + ``setup.py`` ``tests_require`` argument (Twill will only be + downloaded when :mod:`repoze.bfg` ``setup.py test`` or ``setup.py + nosetests`` is invoked). + + 1.2a4 (2009-12-07) ================== diff --git a/repoze/bfg/tests/fixtureapp/another.zcml b/repoze/bfg/tests/fixtureapp/another.zcml index 0ed8cff1b..f8678bad7 100644 --- a/repoze/bfg/tests/fixtureapp/another.zcml +++ b/repoze/bfg/tests/fixtureapp/another.zcml @@ -4,9 +4,7 @@ diff --git a/repoze/bfg/tests/fixtureapp/configure.zcml b/repoze/bfg/tests/fixtureapp/configure.zcml index 4a36d891a..b936b158e 100644 --- a/repoze/bfg/tests/fixtureapp/configure.zcml +++ b/repoze/bfg/tests/fixtureapp/configure.zcml @@ -4,15 +4,11 @@ diff --git a/repoze/bfg/tests/fixtureapp/views.py b/repoze/bfg/tests/fixtureapp/views.py index f805b88c9..82e92d618 100644 --- a/repoze/bfg/tests/fixtureapp/views.py +++ b/repoze/bfg/tests/fixtureapp/views.py @@ -1,7 +1,12 @@ from zope.interface import Interface +from webob import Response def fixture_view(context, request): """ """ + return Response('fixture') + +def renderer_view(request): + return {'a':1} class IDummy(Interface): pass diff --git a/repoze/bfg/tests/test_integration.py b/repoze/bfg/tests/test_integration.py index 9d4a9838d..d210030af 100644 --- a/repoze/bfg/tests/test_integration.py +++ b/repoze/bfg/tests/test_integration.py @@ -7,7 +7,7 @@ from repoze.bfg.view import static from zope.interface import Interface -from repoze.bfg.testing import cleanUp +from repoze.bfg import testing class INothing(Interface): pass @@ -64,20 +64,38 @@ class TestStaticApp(unittest.TestCase): class TestFixtureApp(unittest.TestCase): def setUp(self): - cleanUp() + import sys + import twill + from repoze.bfg.configuration import Configurator + config = Configurator() + config.load_zcml('repoze.bfg.tests.fixtureapp:configure.zcml') + twill.add_wsgi_intercept('localhost', 6543, config.make_wsgi_app) + if sys.platform is 'win32': + out = open('nul:', 'wb') + else: + out = open('/dev/null', 'wb') + twill.set_output(out) + testing.setUp(registry=config.registry) def tearDown(self): - cleanUp() + import twill + import twill.commands + twill.commands.reset_browser() + twill.remove_wsgi_intercept('localhost', 6543) + twill.set_output(None) + testing.tearDown() - def test_execute_actions(self): - import repoze.bfg.tests.fixtureapp as package - from zope.configuration import config - from zope.configuration import xmlconfig - context = config.ConfigurationMachine() - xmlconfig.registerCommonDirectives(context) - context.package = package - xmlconfig.include(context, 'configure.zcml', package) - context.execute_actions(clear=False) + def test_it(self): + import twill.commands + browser = twill.commands.get_browser() + browser.go('http://localhost:6543/another.html') + self.assertEqual(browser.get_code(), 200) + self.assertEqual(browser.get_html(), 'fixture') + browser.go('http://localhost:6543') + self.assertEqual(browser.get_code(), 200) + self.assertEqual(browser.get_html(), 'fixture') + browser.go('http://localhost:6543/dummyskin.html') + self.assertEqual(browser.get_code(), 404) class DummyContext(object): pass diff --git a/setup.py b/setup.py index 1cb62ae9e..6678775fd 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,8 @@ setup(name='repoze.bfg', namespace_packages = ['repoze', 'repoze.bfg'], zip_safe=False, install_requires = install_requires, - tests_require= install_requires + ['Sphinx', 'docutils', 'coverage'], + tests_require= install_requires + ['Sphinx', 'docutils', 'coverage', + 'twill'], test_suite="repoze.bfg.tests", entry_points = """\ [paste.paster_create_template] -- cgit v1.2.3