Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_should_work_even_without_zope_testbrowser(self):
import __builtin__
old_import = __builtin__.__import__
def custom_import(name, *args, **kwargs):
if 'zope' in name:
return None
return old_import(name, *args, **kwargs)
__builtin__.__import__ = custom_import
from splinter import browser
reload(browser)
assert 'zope.testbrowser' not in browser._DRIVERS, 'zope.testbrowser driver should not be registered when zope.testbrowser is not installed'
browser.Browser('zope.testbrowser')
__builtin__.__import__ = old_import
def test_should_work_even_without_zope_testbrowser(self):
self.patch_driver("zope")
from splinter import browser
reload(browser)
self.assertNotIn("zope.testbrowser", browser._DRIVERS)
self.unpatch_driver(browser)
def pytest_addoption(parser): # pragma: no cover
"""Pytest hook to add custom command line option(s)."""
group = parser.getgroup("splinter", "splinter integration for browser testing")
group.addoption(
"--splinter-webdriver",
help="pytest-splinter webdriver", type=str, choices=list(splinter.browser._DRIVERS.keys()),
dest='splinter_webdriver', metavar="DRIVER", default=None)
group.addoption(
"--splinter-remote-url",
help="pytest-splinter remote webdriver url ", metavar="URL", dest='splinter_remote_url', default=None)
group.addoption(
"--splinter-wait-time",
help="splinter explicit wait, seconds", type=int,
dest='splinter_wait_time', metavar="SECONDS", default=None)
group.addoption(
"--splinter-implicit-wait",
help="pytest-splinter selenium implicit wait, seconds", type=int,
dest='splinter_webdriver_implicit_wait', metavar="SECONDS", default=5)
group.addoption(
"--splinter-speed",
help="pytest-splinter selenium speed, seconds", type=int,
dest='splinter_webdriver_speed', metavar="SECONDS", default=0)
def test_should_work_even_without_zope_testbrowser(self):
self.patch_driver("zope")
from splinter import browser
reload(browser)
self.assertNotIn("zope.testbrowser", browser._DRIVERS)
self.unpatch_driver(browser)
def test_should_work_even_without_zope_testbrowser(self):
import __builtin__
old_import = __builtin__.__import__
def custom_import(name, *args, **kwargs):
if 'zope' in name:
return None
return old_import(name, *args, **kwargs)
__builtin__.__import__ = custom_import
from splinter import browser
reload(browser)
assert 'zope.testbrowser' not in browser._DRIVERS, 'zope.testbrowser driver should not be registered when zope.testbrowser is not installed'
browser.Browser('zope.testbrowser')
__builtin__.__import__ = old_import
def test_should_work_even_without_zope_testbrowser(self):
self.patch_driver("zope")
from splinter import browser
reload(browser)
self.assertNotIn("zope.testbrowser", browser._DRIVERS)
self.unpatch_driver(browser)