Skip to content

Commit

Permalink
Add TEST_SCOPE_WSGI_SERVER_FIXTURE and use it in PLONE_ROBOT_TESTING …
Browse files Browse the repository at this point in the history
…layer (used by Volto Cypress tests
  • Loading branch information
datakurre committed May 6, 2022
1 parent 3591014 commit 86abf1d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/plone/app/robotframework/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from plone.app.testing import ploneSite
from plone.testing import Layer
from plone.testing import zope as zope_testing
from plone.testing.zope import WSGIServer
from plone.testing.zope import WSGI_SERVER_FIXTURE
from Products.MailHost.interfaces import IMailHost
from robot.libraries.BuiltIn import BuiltIn
Expand Down Expand Up @@ -136,6 +137,30 @@ def tearDown(self):
# />
#

class TestScopeWSGIServer(WSGIServer):

# Layer where WSGI server is shutdown on testTearDown to prevent requests
# being processed between tests (which could lead to unexpected database
# state).

# Still starts with WSGI server being started at first on suite setUp
# for convenience and similar "RobotServer" experience to the default
# layer.

def testSetUp(self):
if hasattr(self, "server") and self.server.was_shutdown:
super(TestScopeWSGIServer, self).setUp()

def tearDown(self):
pass

def testTearDown(self):
super(TestScopeWSGIServer, self).tearDown()


TEST_SCOPE_WSGI_SERVER_FIXTURE = TestScopeWSGIServer()


RobotRemote = type(
"RobotRemote",
(
Expand Down Expand Up @@ -285,7 +310,7 @@ def __nonzero__(x):
bases=(
PLONE_ROBOT_FIXTURE,
REMOTE_LIBRARY_BUNDLE_FIXTURE,
WSGI_SERVER_FIXTURE,
TEST_SCOPE_WSGI_SERVER_FIXTURE,
),
name="Plone:Robot",
)
Expand Down

0 comments on commit 86abf1d

Please sign in to comment.