zope.testbrowser and WebTest
Hi, I've committed a WebTest integration with testbrowser to a "jinty-webtest" branch. It basically uses WebTest as a backend to drive a WSGI application. This feature makes it possible to do this in a test: >>> app = make_my_wsgi_app() >>> from webtest import TestApp >>> from zope.testbrowser.wsgi import Browser >>> browser = Browser(TestApp(app)) And then use the browser as normal. I've managed to get the existing tests to run against this browser with two new testing dependencies: WebTest zope.app.wsgi If anyone objects to this feature, or wants to review it before I merge, please let me know. I will definitely fix the documentation and remaining test failure before merging. -- Brian Sutherland
On Wed, Dec 15, 2010 at 8:06 AM, Brian Sutherland <brian@vanguardistas.net> wrote:
I've committed a WebTest integration with testbrowser to a "jinty-webtest" branch. It basically uses WebTest as a backend to drive a WSGI application.
This sounds like a nice improvement over using wsgi-intercept (http://code.google.com/p/wsgi-intercept/). I've taken a quick look at the branch. I saw a few of these in the diff: - >>> from zope.testbrowser.testing import Browser + XXX: what to do with this? + XXX>>> from zope.testbrowser.testing import Browser If you can give me some background maybe I can help with these. The copyright date in src/zope/testbrowser/wsgi.py needs the current year. I suspect large chunks of zope.testbrowser.wsgi can be eliminated with judicious refactoring. If you want, I should have time to review your branch again before you merge it. -- Benji York
On Wed, Dec 15, 2010 at 08:53:00AM -0500, Benji York wrote:
On Wed, Dec 15, 2010 at 8:06 AM, Brian Sutherland <brian@vanguardistas.net> wrote:
I've committed a WebTest integration with testbrowser to a "jinty-webtest" branch. It basically uses WebTest as a backend to drive a WSGI application.
This sounds like a nice improvement over using wsgi-intercept (http://code.google.com/p/wsgi-intercept/).
Exactly. I've been using that for a while, but it finally irritated me too much...
I've taken a quick look at the branch. I saw a few of these in the diff:
- >>> from zope.testbrowser.testing import Browser + XXX: what to do with this? + XXX>>> from zope.testbrowser.testing import Browser
If you can give me some background maybe I can help with these.
I now run the tests twice but with a different Browser variable which comes from the test setup. So I need to think of a way of changing the documentation so that it is still clear.
The copyright date in src/zope/testbrowser/wsgi.py needs the current year.
Sure, I'll fix that.
I suspect large chunks of zope.testbrowser.wsgi can be eliminated with judicious refactoring.
As you saw, I took the easy way out by copying testing.py. I wanted to see how easy it was to get the tests passing against WebTest. I'll correct my lazyness shortly ;)
If you want, I should have time to review your branch again before you merge it.
That'd be great. I'll do the refactoring and documentation fixed then ping you again. There's also a single remaining test failure that I may need your help with. -- Brian Sutherland
On Wed, Dec 15, 2010 at 08:53:00AM -0500, Benji York wrote:
If you want, I should have time to review your branch again before you merge it.
Ok, I've done some minimal refactoring and am ready to merge the branch when you've reviewed it. -- Brian Sutherland
On Wed, Dec 15, 2010 at 8:06 AM, Brian Sutherland <brian@vanguardistas.net> wrote:
Hi,
I've committed a WebTest integration with testbrowser to a "jinty-webtest" branch. It basically uses WebTest as a backend to drive a WSGI application.
This feature makes it possible to do this in a test:
>>> app = make_my_wsgi_app() >>> from webtest import TestApp >>> from zope.testbrowser.wsgi import Browser >>> browser = Browser(TestApp(app))
And then use the browser as normal.
I've managed to get the existing tests to run against this browser with two new testing dependencies: WebTest zope.app.wsgi
If anyone objects to this feature, or wants to review it before I merge, please let me know. I will definitely fix the documentation and remaining test failure before merging.
I'm not volunteering to review :), but this enhancement sounds great! Jim -- Jim Fulton
On Wed, Dec 15, 2010 at 2:06 PM, Brian Sutherland <brian@vanguardistas.net> wrote:
I've managed to get the existing tests to run against this browser with two new testing dependencies: WebTest zope.app.wsgi
zope.app.wsgi shouldn't be a dependency of zope.testbrowser. It's ok if it's pulled in via a specific extra_requires like a [webtest] extra, though. Zope2 depends on zope.testbrowser and has no dependency on any zope.app packages - this must continue to be the case. Required test dependencies count towards real dependencies here. The real fix would probably be to move the reusable code out of zope.app.wsgi into a zope.wsgi package, but that might be more than you are willing to do now. I do believe some of the Grok people would be interested in this as well. Hanno
On Thu, Dec 16, 2010 at 12:06:36AM +0100, Hanno Schlichting wrote:
On Wed, Dec 15, 2010 at 2:06 PM, Brian Sutherland <brian@vanguardistas.net> wrote:
I've managed to get the existing tests to run against this browser with two new testing dependencies: WebTest zope.app.wsgi
zope.app.wsgi shouldn't be a dependency of zope.testbrowser. It's ok if it's pulled in via a specific extra_requires like a [webtest] extra, though. Zope2 depends on zope.testbrowser and has no dependency on any zope.app packages - this must continue to be the case. Required test dependencies count towards real dependencies here.
I understand your point, but the situation was already pretty nasty as zope.testbrowser already depended on: zope.app.appsetup zope.app.publication zope.app.testing >= 3.8 I agree that any extra dependency is not welcome, but this feature opens up a path to radically reducing the dependencies of zope.testbrowser. See below.
The real fix would probably be to move the reusable code out of zope.app.wsgi into a zope.wsgi package, but that might be more than you are willing to do now. I do believe some of the Grok people would be interested in this as well.
There is also another route open now with the addition of the webtest feature. We could invert the zope.testbrowser -> zope.app.testing dependency. This is a major re-factoring, but will leave the zope.testbrowser dependencies looking like this: install_requires = [ 'mechanize>=0.2.0', 'setuptools', 'zope.interface', 'zope.schema', 'pytz', ], extras_require = { 'test': [ 'WebOb', 'WebTest', ] Basically this would require: * Re-writing the zope.testbrowser.ftests test application as a pure WSGI app (using WebOb) * Test only against zope.testbrowser.wsgi and refactor tests to not use features from zope.app.testing.functional * Move zope.testbrowser.testing into zope.testbrowser.wsgi and zope.app.testing.testbrowser * Leave backwards compatibility imports in place in zope.testbrowser.testing I'd be willing to have a look at this if Benji were OK in principle on this and someone was willing to review it. -- Brian Sutherland
On 16 December 2010 08:38, Brian Sutherland <brian@vanguardistas.net> wrote:
On Thu, Dec 16, 2010 at 12:06:36AM +0100, Hanno Schlichting wrote:
On Wed, Dec 15, 2010 at 2:06 PM, Brian Sutherland <brian@vanguardistas.net> wrote:
I've managed to get the existing tests to run against this browser with two new testing dependencies: WebTest zope.app.wsgi
zope.app.wsgi shouldn't be a dependency of zope.testbrowser. It's ok if it's pulled in via a specific extra_requires like a [webtest] extra, though. Zope2 depends on zope.testbrowser and has no dependency on any zope.app packages - this must continue to be the case. Required test dependencies count towards real dependencies here.
I understand your point, but the situation was already pretty nasty as zope.testbrowser already depended on:
zope.app.appsetup zope.app.publication zope.app.testing >= 3.8
I agree that any extra dependency is not welcome, but this feature opens up a path to radically reducing the dependencies of zope.testbrowser. See below.
The real fix would probably be to move the reusable code out of zope.app.wsgi into a zope.wsgi package, but that might be more than you are willing to do now. I do believe some of the Grok people would be interested in this as well.
There is also another route open now with the addition of the webtest feature. We could invert the zope.testbrowser -> zope.app.testing dependency.
This is a major re-factoring, but will leave the zope.testbrowser dependencies looking like this:
install_requires = [ 'mechanize>=0.2.0', 'setuptools', 'zope.interface', 'zope.schema', 'pytz', ], extras_require = { 'test': [ 'WebOb', 'WebTest', ]
Basically this would require:
* Re-writing the zope.testbrowser.ftests test application as a pure WSGI app (using WebOb) * Test only against zope.testbrowser.wsgi and refactor tests to not use features from zope.app.testing.functional * Move zope.testbrowser.testing into zope.testbrowser.wsgi and zope.app.testing.testbrowser * Leave backwards compatibility imports in place in zope.testbrowser.testing
I'd be willing to have a look at this if Benji were OK in principle on this and someone was willing to review it.
-- Brian Sutherland _______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Hi Brian, I'd be happy to contribute to your zope.testbrowser refactoring. I am primarily interested from the perspective of grok and zope.app.wsgi. -- Jan-Jaap Driessen
participants (5)
-
Benji York -
Brian Sutherland -
Hanno Schlichting -
Jan-Jaap Driessen -
Jim Fulton