transfered from bitbucket:
Michael Howitz created an issue 2016-09-07
Originally posted by @wosc at https://projects.gocept.com/issues/13492
We should add pytest fixtures in addition to zope.testrunner Layers.
Here's a concrete example (depends on fixtures @Application, application_session@ to provide the WSGI callable), I'm not sure how to extract this generically.
@pytest.fixture(scope='session')
def httpserver(application_session, request):
server = gocept.httpserverlayer.wsgi.Layer()
server.wsgi_app = application_session
server.setUp()
server.url = 'http://%s' % server['http_address']
request.addfinalizer(server.tearDown)
return server
@pytest.fixture(scope='session')
def webdriver(httpserver, request):
layer = gocept.selenium.WebdriverLayer(name='WebdriverLayer')
layer['http_address'] = httpserver['http_address']
layer.setUp()
request.addfinalizer(layer.tearDown)
return layer
@pytest.fixture
def selenium(webdriver, httpserver, application, request):
auth = 'admin:admin'
timeout = int(os.environ.get('GOCEPT_SELENIUM_TIMEOUT', 10))
selenium = gocept.selenium.wd_selenese.Selenese(
webdriver['seleniumrc'],
'%s@%s' % (auth, httpserver['http_address']), timeout)
request.addfinalizer(lambda: selenium.open('/ping'))
return selenium
def pytest_configure(config):
# On DEBUG, selenium logs low-level webdriver communication, which includes
# a base64 dump of the Firefox profile, which really nobody wants to see.
logging.getLogger('selenium').setLevel(logging.INFO)
Comments (0)
transfered from bitbucket: