适用于功能黑盒测试的可编程浏览器
项目描述
zope.testbrowser 提供了一个易于使用的可编程网络浏览器,特别关注测试。它在Zope中使用,但并非仅限于Zope。例如,它可以用于测试或以其他方式与任何网站进行交互。
文档可在: https://zopetestbrowser.readthedocs.org 获取
变更记录
7.0 (2024-05-31)
从3.13b1开始支持Python 3.12和3.13。
放弃对Python 3.7的支持。
6.0 (2023-03-27)
放弃对Python 2.7、3.5和3.6的支持。
放弃对已弃用的 python setup.py test 的支持。
支持Python 3.11。
在直接调用 browser.open 或 browser.post 时,确保 mechRepr 不会中断。
5.6.1 (2022-01-21)
确保所有对象具有一致的解析顺序。
5.6.0 (2022-01-21)
支持Python 3.9和3.10。
5.5.1 (2019-11-12)
5.5.0 (2019-11-11)
5.4.0 (2019-11-01)
5.3.3 (2019-07-02)
5.3.2 (2019-02-06)
5.3.1 (2018-10-23)
修复了在Python 3上出现的DeprecationWarning。请参阅问题51。
5.3.0 (2018-10-10)
添加对Python 3.7的支持。
停止支持Python 3.3和3.4。
由于Python 3.7停止了pystone,因此不再支持pystone。因此,Browser.lastRequestPystones不再存在。将.browser.PystoneTimer重命名为.browser.Timer。
修复了CheckboxListControl的mechRepr,使其始终返回一个本地str。(https://github.com/zopefoundation/zope.testbrowser/pull/46)。
为具有类型email的输入字段添加了mechRepr。(https://github.com/zopefoundation/zope.testbrowser/pull/47)。
5.2.4 (2017-11-24)
修复了当表单操作包含查询字符串时使用GET方法提交表单的bug。(https://github.com/zopefoundation/zope.testbrowser/pull/42)。
在通过标签搜索时恢复忽略隐藏元素。(https://github.com/zopefoundation/zope.testbrowser/pull/41)。
5.2.3 (2017-10-18)
修复了控件上的mechRepr,使其始终返回一个本地str。(https://github.com/zopefoundation/zope.testbrowser/issues/38)。
5.2.2 (2017-10-10)
在尝试设置只读控件的值时恢复引发AttributeError。
修复了通过索引选择单选按钮和选择控件选项的bug。(https://github.com/zopefoundation/zope.testbrowser/issues/31)。
5.2.1 (2017-09-01)
由于它破坏了某些测试,因此排除WebTest的版本2.0.27。
适配WebTest的版本2.0.28,但保持与旧版本兼容。
5.2 (2017-02-25)
修复 toStr 以处理列表,例如类名列表。[maurits]
修复浏览器只跟随HTTP状态码301、302、303和307的重定向;不跟随其他30x状态码,如304。
修复将实际文件传递给 add_file。
为Form类添加 controls 属性,以列出所有表单控件。
恢复使用实际显示的复选框标题部分的能力。
允许在 Browser.displayValue 上设置字符串值而不是列表。
修复在选择控件上设置空值的问题。
支持Python 3.6、PyPy2.7和PyPy3.3。
5.1 (2017-01-31)
将 .browser.urllib_request.HTTPError 别名为 .browser.HTTPError 以获得更好的API。
5.0.0 (2016-09-30)
将大多数doctests转换为Sphinx文档,并发布到 https://zopetestbrowser.readthedocs.io/ .
内部实现现在使用WebTest而不是 mechanize。完全删除了 mechanize 依赖。 这是一个向后不兼容的更改。
移除API
zope.testbrowser.testing.Browser(这是一个很大的更改)。
现在,您不再使用 zope.testbrowser.testing.Browser() 并依赖于它神奇地获取 zope.app.testing.functional 单例应用程序,您必须定义一个继承自 zope.testbrowser.wsgi.Layer 的测试层,重写 make_wsgi_app 方法以创建WSGI应用程序,然后在测试中使用 zope.testbrowser.wsgi.Browser()。
(或者您可以根据自己的喜好设置一个WSGI应用程序,并将其显式传递给 zope.testbrowser.browser.Browser(wsgi_app=my_app)。)
示例:如果您的测试文件看起来像这样
# my/package/tests.py from zope.app.testing.functional import defineLayer from zope.app.testing.functional import FunctionalDocFileSuite defineLayer('MyFtestLayer', 'ftesting.zcml', allow_teardown=True) def test_suite(): suite = FunctionalDocFileSuite('test.txt', ...) suite.layer = MyFtestLayer return suite
现在您必须使用
# my/package/tests.py from unittest import TestSuite import doctest import zope.app.wsgi.testlayer import zope.testbrowser.wsgi class Layer(zope.testbrowser.wsgi.TestBrowserLayer, zope.app.wsgi.testlayer.BrowserLayer): """Layer to prepare zope.testbrowser using the WSGI app.""" layer = Layer(my.package, 'ftesting.zcml', allowTearDown=True) def test_suite(): suite = doctest.DocFileSuite('test.txt', ...) suite.layer = layer return suite
然后更改所有测试
>>> from zope.testbrowser.testing import Browser
到
>>> from zope.testbrowser.wsgi import Browser
也许博客文章 摆脱zope.app.testing 也能帮助您适应这个新版本。
移除模块
zope.testbrowser.connection
移除您本来就不应该使用的内部类
zope.testbrowser.testing.PublisherResponse
zope.testbrowser.testing.PublisherConnection
zope.testbrowser.testing.PublisherHTTPHandler
zope.testbrowser.testing.PublisherMechanizeBrowser
zope.testbrowser.wsgi.WSGIConnection
zope.testbrowser.wsgi.WSGIHTTPHandler
zope.testbrowser.wsgi.WSGIMechanizeBrowser
移除您本来就不应该使用的内部属性(此列表可能不完整)
Browser._mech_browser
移除setuptools extras
zope.testbrowser[zope-functional-testing]
行为更改
testbrowser不再跟随HTML重定向,即 <meta http-equiv="refresh" ... />。这是一个 mechanize 功能,似乎不提供 WebTest。
添加对Python 3.3、3.4和3.5的支持。
放弃对Python 2.5和2.6的支持。
放弃对 WebTest <= 1.3.4 的限制。我们现在需要 WebTest >= 2.0.8。
放弃对已弃用的 zope.app.testing 的依赖。
错误修复:如果您的HTML包含没有href属性的 <a> 元素,则 browser.getLink() 可能会失败(https://github.com/zopefoundation/zope.testbrowser/pull/3)。
4.0.3 (2013-09-04)
锁定版本‘WebTest <= 1.3.4’,因为某些不兼容性和测试失败
使zope.testbrowser可通过pip安装(https://github.com/zopefoundation/zope.testbrowser/issues/6)。
当 Browser.handleErrors 为False时,也将 x-wsgiorg.throw_errors 添加到环境。 http://wsgi.org/wsgi/Specifications/throw_errors
通过在Browser.handleErrors为True时将其设置为None,防止WebTest在环境中始终发送paste.throw_errors=True。这使得测试错误页面变得更加容易。
使Browser.submit()处理raiseHttpErrors(https://github.com/zopefoundation/zope.testbrowser/pull/4)。
从getControl()等处获得更友好的错误信息
当您指定的索引超出范围时,显示所有可用选项
当您无法找到任何内容时,显示所有可用项
4.0.2 (2011-05-25)
删除对zope.pagetemplate的测试依赖。
4.0.1 (2011-05-04)
在文档中添加提示,说明如何使用zope.testbrowser.wsgi.Browser来测试Zope 2/Zope 3/Bluebream WSGI应用程序。
4.0.0 (2011-03-14)
LP #721252:AmbiguityError现在显示所有匹配的控制。
与WebTest集成。 zope.testbrowser.wsgi.Browser是一个使用webtest.TestApp驱动WSGI应用程序的Browser实现。这取代了3.11中添加的wsgi_intercept支持。
使用WebTest基于的Browser运行现有测试,将测试应用程序重写为使用WebOb的纯WSGI应用程序。
将基于zope.app.testing的Browser移动到zope.app.testing中(保留 backwards compatibility imports)。在zope.app.testing 3.9.0中发布。
3.11.1 (2011-01-24)
修复brown bag发布3.11.0。
3.11.0 (2011-01-24)
添加对wsgi_intercept的支持(来自zope.app.wsgi.testlayer)。
3.10.4 (2011-01-14)
将over-the-wire.txt doctest从TestBrowserLayer中移除,因为它不需要或使用它。
修复与zope.app.testing 3.8.1的测试兼容性。
3.10.3 (2010-10-15)
修复与zope.app.wsgi.testlayer的向后兼容性。
3.10.2 (2010-10-15)
修复了Browser.handleErrors中的Python 2.7兼容性问题。
3.10.1 (2010-09-21)
修复了一个导致Browser保留其先前contents的bug。这些地方是:- Link.click() - SubmitControl.click() - ImageControl.click() - Form.submit()
还将上述位置的异常信息调整为与版本3.4.1之前的消息匹配。
3.10.0 (2010-09-14)
LP #98437:使用mechanize的内置submit()提交表单,允许mechanize适当地设置“Referer:”(sic)头。
修复了与zope.app.testing 3.8及更高版本兼容的测试。
3.9.0 (2010-05-17)
LP #568806:更新依赖项mechanize >= 0.2.0,它现在包括ClientForm API。删除对urllib2 API的使用(与mechanize 0.2.0不兼容),转而使用mechanize等效。感谢John J. Lee提供的补丁。
使用stdlib doctest模块,而不是zope.testing.doctest。
注意:此版本不再与Python 2.4完全兼容:handleErrors = False不再工作。
3.8.1 (2010-04-19)
将mechanize依赖项固定,以防止在我们有时间调整其API更改之前使用即将发布的0.2.0版本。
修复LP #98396:testbrowser解析相对URL不正确。
3.8.0 (2010-03-05)
添加了follow便利方法,该方法获取并跟随一个链接。
3.7.0 (2009-12-17)
将zope.app.testing依赖项移动到PublisherConnection类的范围内。Zope2指定了自己的PublisherConnection版本,该版本不依赖于zope.app.testing。
修复LP #419119:当浏览器没有内容时返回None,而不是抛出异常。
3.7.0a1(2009-08-29)
将依赖项从 zope.app.publisher 更新到 zope.browserpage、zope.browserresource 和 zope.ptresource。
通过使用简单的 PermissiveSecurityPolicy 移除对 zope.app.principalannotation 和 zope.securitypolicy 的依赖。
将测试依赖项 zope.app.zcmlfiles 替换为最小集合包的显式依赖。
从 ftesting.zcml 中移除不必要的 zope.app.authentication。
将依赖项从 zope.app.securitypolicy 更新到 zope.securitypolicy。
3.6.0a2 (2009-01-31)
将依赖项从 zope.app.folder 更新到 zope.site.folder。
从 zope.app.component 中移除不必要的测试依赖。
3.6.0a1 (2009-01-08)
将作者电子邮件更新为 zope-dev 而不是 zope3-dev。
不再从包含在 <textarea> 中的 XML 和 HTML 代码中删除换行符;此修复需要 ClientForm >= 0.2.10(LP #268139)。
向浏览器添加 cookies 属性,以便轻松操作浏览器 cookie。请参阅主要文档中的简要示例以及新的 cookies.txt 文档。
3.5.1 (2008-10-10)
解决 Python 2.6 上 mechanize/urllib2 缺失 Request 基类中的 timeout 属性的 Bug。
解决在创建不会正确处理片段 URL 的请求对象时 mechanize/urllib2 中的 Bug。
3.5.0 (2008-03-30)
添加一个 zope.testbrowser.testing.Browser.post 方法,允许测试提供正文和内容类型。这对于测试非表单输入(例如 JSON)的 Ajax 请求很有用。
移除对 mechanize 的供应商导入。
修复导致 HTTP 异常回溯在版本 3.4.0 和 3.4.1 之间不同的 Bug。
解决 Python Cookie.SimpleCookie 在处理 Unicode 字符串时的 Bug。
修复在 3.4.1 中引入的 Bug,该 Bug 导致 doctests 中的不兼容回溯。这需要将修复后的 mechanize 添加到源树中;补丁已发送到 mechanize 项目。
通过添加 zope.interface 和 zope.schema 作为实际依赖项来解决 https://bugs.launchpad.net/bugs/149517。
修复 browser.getLink 文档,该文档自上次 API 修改以来未更新。
将修复的 Bug 的测试移动到单独的文件。
移除旨在帮助使用虚拟主机测试服务器的非功能性且未记录的代码。
3.4.2 (2007-10-31)
解决 ZopeSecurityPolicy 弃用警告。
3.4.1 (2007-09-01)
更新依赖项为 mechanize 0.1.7b 和 ClientForm 0.2.7。
添加对 Python 2.5 的支持。
3.4.0 (2007-06-04)
添加抑制在 HTTP 错误上引发异常的功能(raiseHttpErrors 属性)。
使用 REnormalizer 使测试更能够抵御 HTTP 头格式更改。
3.4.0a1 (2007-04-22)
作为独立项目发布,对应于 Zope 3.4.0a1 中的 zope.testbrowser
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
构建分发
zope.testbrowser-7.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 5936d2a0d77d8781d001358fd0b11461285b02dc6e3b324b84c1ed9326b1ff3f |
|
MD5 | 4804b3c956294d11d3c6f9ab0711ab1a |
|
BLAKE2b-256 | 465fdb2128c4dc3cc3077d2652ba2232685fb2f8c0ee6bd970b2dbf165ef7a54 |
zope.testbrowser-7.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 75fa5f63f69fe4ebd6e6a7cebf2dc7da61a4c2a248f69b0b171d218af51a860e |
|
MD5 | e9c9aa452b05266f7631c40752b8e4fe |
|
BLAKE2b-256 | 84777e1cd9022a41bb3294b735f460b8a7ec59c3d0ba0e8b1f84d8a3674615e0 |