From 34d78c5b9baa957f32669a8820ed59000799ac84 Mon Sep 17 00:00:00 2001 From: thet Date: Fri, 29 Jan 2016 02:38:39 +0100 Subject: [PATCH] [fc] Repository: plone.testing Branch: refs/heads/master Date: 2016-01-28T15:48:22+01:00 Author: Johannes Raggam (thet) Commit: https://github.com/plone/plone.testing/commit/431c75734548536b6dddf98bffa26669422652dc Fix tests for Zope 4, where the app root Control_Panel is not available anymore. Files changed: M CHANGES.rst M src/plone/testing/z2.rst Repository: plone.testing Branch: refs/heads/master Date: 2016-01-29T02:38:39+01:00 Author: Johannes Raggam (thet) Commit: https://github.com/plone/plone.testing/commit/0e786482d27012de1349e398e98db2ce9ab852fd Merge pull request #18 from plone/thet-zope4 Zope4 Files changed: M CHANGES.rst M src/plone/testing/z2.rst --- last_commit.txt | 481 ++++++++++++++++++++++++++++-------------------- 1 file changed, 277 insertions(+), 204 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index e4523dbbff..2adbec94fa 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,237 +1,310 @@ -Repository: plone.rfc822 +Repository: plone.testing Branch: refs/heads/master -Date: 2016-01-25T17:53:48+01:00 +Date: 2016-01-28T15:48:22+01:00 Author: Johannes Raggam (thet) -Commit: https://github.com/plone/plone.rfc822/commit/0bc362c3df0d3a9560d89764ff525014a6d96747 +Commit: https://github.com/plone/plone.testing/commit/431c75734548536b6dddf98bffa26669422652dc -Replace deprecated zope.testing.doctest import with doctest module from stdlib. +Fix tests for Zope 4, where the app root Control_Panel is not available anymore. Files changed: -M docs/HISTORY.txt -M plone/rfc822/tests.py +M CHANGES.rst +M src/plone/testing/z2.rst -diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt -index 58b77e5..7644ecf 100644 ---- a/docs/HISTORY.txt -+++ b/docs/HISTORY.txt -@@ -4,7 +4,9 @@ Changelog - 1.1.2 (unreleased) - ------------------ - --- Nothing changed yet. -+- Replace deprecated ``zope.testing.doctest`` import with ``doctest`` module -+ from stdlib. +diff --git a/CHANGES.rst b/CHANGES.rst +index 733f7ce..4474216 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -10,7 +10,8 @@ New: + + Fixes: + +-- *add item here* ++- Fix tests for Zope 4, where the app root Control_Panel is not available anymore. + [thet] - 1.1.1 (2015-03-21) -diff --git a/plone/rfc822/tests.py b/plone/rfc822/tests.py -index 62f442a..fc7c711 100644 ---- a/plone/rfc822/tests.py -+++ b/plone/rfc822/tests.py -@@ -1,5 +1,5 @@ - import unittest --from zope.testing import doctest -+import doctest - import zope.component.testing + 4.1.0 (2016-01-08) +diff --git a/src/plone/testing/z2.rst b/src/plone/testing/z2.rst +index b16280a..19cf7bb 100644 +--- a/src/plone/testing/z2.rst ++++ b/src/plone/testing/z2.rst +@@ -67,23 +67,23 @@ At this point, it is also possible to get hold of a Zope application root. + If you are setting up a layer fixture, you can obtain an application root with the correct database that is properly closed by using the ``zopeApp()`` context manager.:: - def test_suite(): - - -Repository: plone.rfc822 - - -Branch: refs/heads/master -Date: 2016-01-26T14:09:02+01:00 -Author: Johannes Raggam (thet) -Commit: https://github.com/plone/plone.rfc822/commit/8914d58bb7f2e0be20cd47e02f73a863579773d6 - -Fix test isolation problem. - -Files changed: -M docs/HISTORY.txt -M plone/rfc822/tests.py -M setup.py - -diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt -index 7644ecf..a6c7e6e 100644 ---- a/docs/HISTORY.txt -+++ b/docs/HISTORY.txt -@@ -4,8 +4,10 @@ Changelog - 1.1.2 (unreleased) - ------------------ - --- Replace deprecated ``zope.testing.doctest`` import with ``doctest`` module -- from stdlib. -+- Fix test isolation problem. -+ [thet] -+ -+- Replace deprecated ``zope.testing.doctest`` import with ``doctest`` module from stdlib. - [thet] - - -diff --git a/plone/rfc822/tests.py b/plone/rfc822/tests.py -index fc7c711..3679ca6 100644 ---- a/plone/rfc822/tests.py -+++ b/plone/rfc822/tests.py -@@ -1,23 +1,29 @@ - import unittest - import doctest --import zope.component.testing -+from plone.testing import layered -+from plone.testing.zca import UNIT_TESTING -+ -+ -+DOCFILES = [ -+ 'message.txt', -+ 'fields.txt', -+ 'supermodel.txt', -+] -+ -+optionflags = doctest.ELLIPSIS + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() ++ True + + If you want to use a specific database, you can pass that to ``zopeApp()`` as the ``db`` parameter. + A new connection will be opened and closed.:: + + >>> with z2.zopeApp(db=z2.STARTUP['zodbDB']) as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() ++ True + + If you want to re-use an existing connection, you can pass one to ``zopeApp()`` as the ``connection`` argument. + In this case, you will need to close the connection yourself.:: + + >>> conn = z2.STARTUP['zodbDB'].open() + >>> with z2.zopeApp(connection=conn) as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() ++ True + + >>> conn.opened is not None + True +@@ -211,8 +211,8 @@ The test may now inspect and modify the environment.:: + + >>> app = z2.INTEGRATION_TESTING['app'] # would normally be self.layer['app'] + >>> app.manage_addFolder('folder1') +- >>> app.objectIds() +- ['acl_users', 'Control_Panel', 'folder1'] ++ >>> 'acl_users' and 'folder1' in app.objectIds() ++ True + + The request is also available::: + +@@ -260,8 +260,9 @@ On tear-down, the transaction is rolled back::: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + - def test_suite(): - -- return unittest.TestSuite(( -- doctest.DocFileSuite( -- 'message.txt', -- tearDown=zope.component.testing.tearDown(), -- optionflags=doctest.ELLIPSIS -- ), -- doctest.DocFileSuite( -- 'fields.txt', -- tearDown=zope.component.testing.tearDown(), -- optionflags=doctest.ELLIPSIS -- ), -+ suite = unittest.TestSuite() -+ suite.addTests([ -+ layered( - doctest.DocFileSuite( -- 'supermodel.txt', -- tearDown=zope.component.testing.tearDown(), -- optionflags=doctest.ELLIPSIS -+ docfile, -+ optionflags=optionflags, - ), -- )) -+ layer=UNIT_TESTING -+ ) -+ for docfile in DOCFILES -+ ]) -+ return suite -diff --git a/setup.py b/setup.py -index 7390cb1..ff34541 100644 ---- a/setup.py -+++ b/setup.py -@@ -27,6 +27,7 @@ - zip_safe=False, - extras_require={ - 'supermodel': ['plone.supermodel'], -+ 'test': ['plone.testing'], - }, - install_requires=[ - 'setuptools', + Let's tear down the layers::: + +@@ -312,8 +313,8 @@ It may also commit things.:: + + >>> app = z2.FUNCTIONAL_TESTING['app'] # would normally be self.layer['app'] + >>> app.manage_addFolder('folder1') +- >>> app.objectIds() +- ['acl_users', 'Control_Panel', 'folder1'] ++ >>> 'acl_users' and 'folder1' in app.objectIds() ++ True + + >>> import transaction + >>> transaction.commit() +@@ -330,8 +331,8 @@ On tear-down, the database is torn down.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + + Let's tear down the layer::: + +@@ -420,8 +421,10 @@ On tear-down, the database is torn down.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds()\ ++ ... and 'folder1' not in app.objectIds()\ ++ ... and 'file1' not in app.objectIds() ++ True + + Let's tear down the layer::: + +@@ -513,8 +516,8 @@ Test tear-down does nothing beyond what the base layers do.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + + When the server is torn down, the ZServer thread is stopped.:: + +@@ -611,8 +614,7 @@ We can now look for this new object through the server.:: + + >>> ftpClient.retrlines('LIST') + drwxrwx--- 1 Zope Zope 0 ... . +- drwxrwx--- 1 Zope Zope 0 ... Control_Panel +- --w--w---- 1 Zope Zope 0 ... acl_users ++ ...--w--w---- 1 Zope Zope 0 ... acl_users + drwxrwx--- 1 Zope Zope 0 ... folder1 + '226 Transfer complete' + +@@ -632,8 +634,8 @@ Test tear-down does nothing beyond what the base layers do.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + + When the server is torn down, the FTP thread is stopped.:: + -Repository: plone.rfc822 +Repository: plone.testing Branch: refs/heads/master -Date: 2016-01-29T02:26:58+01:00 +Date: 2016-01-29T02:38:39+01:00 Author: Johannes Raggam (thet) -Commit: https://github.com/plone/plone.rfc822/commit/345b087127f55abeea57d87616f2bf8165bb01d5 +Commit: https://github.com/plone/plone.testing/commit/0e786482d27012de1349e398e98db2ce9ab852fd -Merge pull request #1 from plone/thet-zope4 +Merge pull request #18 from plone/thet-zope4 Zope4 Files changed: -M docs/HISTORY.txt -M plone/rfc822/tests.py -M setup.py +M CHANGES.rst +M src/plone/testing/z2.rst -diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt -index 58b77e5..a6c7e6e 100644 ---- a/docs/HISTORY.txt -+++ b/docs/HISTORY.txt -@@ -4,7 +4,11 @@ Changelog - 1.1.2 (unreleased) - ------------------ - --- Nothing changed yet. -+- Fix test isolation problem. -+ [thet] -+ -+- Replace deprecated ``zope.testing.doctest`` import with ``doctest`` module from stdlib. +diff --git a/CHANGES.rst b/CHANGES.rst +index 733f7ce..4474216 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -10,7 +10,8 @@ New: + + Fixes: + +-- *add item here* ++- Fix tests for Zope 4, where the app root Control_Panel is not available anymore. + [thet] - 1.1.1 (2015-03-21) -diff --git a/plone/rfc822/tests.py b/plone/rfc822/tests.py -index 62f442a..3679ca6 100644 ---- a/plone/rfc822/tests.py -+++ b/plone/rfc822/tests.py -@@ -1,23 +1,29 @@ - import unittest --from zope.testing import doctest --import zope.component.testing -+import doctest -+from plone.testing import layered -+from plone.testing.zca import UNIT_TESTING -+ -+ -+DOCFILES = [ -+ 'message.txt', -+ 'fields.txt', -+ 'supermodel.txt', -+] -+ -+optionflags = doctest.ELLIPSIS + 4.1.0 (2016-01-08) +diff --git a/src/plone/testing/z2.rst b/src/plone/testing/z2.rst +index b16280a..19cf7bb 100644 +--- a/src/plone/testing/z2.rst ++++ b/src/plone/testing/z2.rst +@@ -67,23 +67,23 @@ At this point, it is also possible to get hold of a Zope application root. + If you are setting up a layer fixture, you can obtain an application root with the correct database that is properly closed by using the ``zopeApp()`` context manager.:: + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() ++ True + + If you want to use a specific database, you can pass that to ``zopeApp()`` as the ``db`` parameter. + A new connection will be opened and closed.:: + + >>> with z2.zopeApp(db=z2.STARTUP['zodbDB']) as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() ++ True + + If you want to re-use an existing connection, you can pass one to ``zopeApp()`` as the ``connection`` argument. + In this case, you will need to close the connection yourself.:: + + >>> conn = z2.STARTUP['zodbDB'].open() + >>> with z2.zopeApp(connection=conn) as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() ++ True + + >>> conn.opened is not None + True +@@ -211,8 +211,8 @@ The test may now inspect and modify the environment.:: + + >>> app = z2.INTEGRATION_TESTING['app'] # would normally be self.layer['app'] + >>> app.manage_addFolder('folder1') +- >>> app.objectIds() +- ['acl_users', 'Control_Panel', 'folder1'] ++ >>> 'acl_users' and 'folder1' in app.objectIds() ++ True + + The request is also available::: + +@@ -260,8 +260,9 @@ On tear-down, the transaction is rolled back::: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + - def test_suite(): - -- return unittest.TestSuite(( -- doctest.DocFileSuite( -- 'message.txt', -- tearDown=zope.component.testing.tearDown(), -- optionflags=doctest.ELLIPSIS -- ), -- doctest.DocFileSuite( -- 'fields.txt', -- tearDown=zope.component.testing.tearDown(), -- optionflags=doctest.ELLIPSIS -- ), -+ suite = unittest.TestSuite() -+ suite.addTests([ -+ layered( - doctest.DocFileSuite( -- 'supermodel.txt', -- tearDown=zope.component.testing.tearDown(), -- optionflags=doctest.ELLIPSIS -+ docfile, -+ optionflags=optionflags, - ), -- )) -+ layer=UNIT_TESTING -+ ) -+ for docfile in DOCFILES -+ ]) -+ return suite -diff --git a/setup.py b/setup.py -index 7390cb1..ff34541 100644 ---- a/setup.py -+++ b/setup.py -@@ -27,6 +27,7 @@ - zip_safe=False, - extras_require={ - 'supermodel': ['plone.supermodel'], -+ 'test': ['plone.testing'], - }, - install_requires=[ - 'setuptools', + Let's tear down the layers::: + +@@ -312,8 +313,8 @@ It may also commit things.:: + + >>> app = z2.FUNCTIONAL_TESTING['app'] # would normally be self.layer['app'] + >>> app.manage_addFolder('folder1') +- >>> app.objectIds() +- ['acl_users', 'Control_Panel', 'folder1'] ++ >>> 'acl_users' and 'folder1' in app.objectIds() ++ True + + >>> import transaction + >>> transaction.commit() +@@ -330,8 +331,8 @@ On tear-down, the database is torn down.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + + Let's tear down the layer::: + +@@ -420,8 +421,10 @@ On tear-down, the database is torn down.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds()\ ++ ... and 'folder1' not in app.objectIds()\ ++ ... and 'file1' not in app.objectIds() ++ True + + Let's tear down the layer::: + +@@ -513,8 +516,8 @@ Test tear-down does nothing beyond what the base layers do.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + + When the server is torn down, the ZServer thread is stopped.:: + +@@ -611,8 +614,7 @@ We can now look for this new object through the server.:: + + >>> ftpClient.retrlines('LIST') + drwxrwx--- 1 Zope Zope 0 ... . +- drwxrwx--- 1 Zope Zope 0 ... Control_Panel +- --w--w---- 1 Zope Zope 0 ... acl_users ++ ...--w--w---- 1 Zope Zope 0 ... acl_users + drwxrwx--- 1 Zope Zope 0 ... folder1 + '226 Transfer complete' + +@@ -632,8 +634,8 @@ Test tear-down does nothing beyond what the base layers do.:: + False + + >>> with z2.zopeApp() as app: +- ... print app.objectIds() +- ['acl_users', 'Control_Panel'] ++ ... 'acl_users' in app.objectIds() and 'folder1' not in app.objectIds() ++ True + + When the server is torn down, the FTP thread is stopped.:: +