Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.s = http.StopableWSGIServer.create(debug_app)
self.s.wait()
def __init__(self, app=None, url=None, timeout=30000,
extra_environ=None, relative_to=None, **kwargs):
self.app = self.server = None
if app:
super(SeleniumApp, self).__init__(app, relative_to=relative_to)
self.server = http.StopableWSGIServer.create(app)
self.server.wait()
url = self.server.application_url
assert is_available()
self.session_id = None
self._browser = Selenium()
self._browser.start(url)
self.extra_environ = extra_environ or {}
self.timeout = timeout
self.test_app = self
def setUp(self):
self.s = http.StopableWSGIServer.create(debug_app)
def is_available():
"""return True if the selenium module is available and a RC server is
running"""
host = os.environ.get('SELENIUM_HOST', '127.0.0.1')
port = int(os.environ.get('SELENIUM_PORT', 4444))
if not http.check_server(host, port, retries=1):
if 'SELENIUM_JAR' not in os.environ:
return False
else:
jar = os.environ['SELENIUM_JAR']
p = subprocess.Popen(['java', '-jar', jar])
os.environ['SELENIUM_PID'] = str(p.pid)
return http.check_server(host, port)
return True
def is_available():
"""return True if the selenium module is available and a RC server is
running"""
host = os.environ.get('SELENIUM_HOST', '127.0.0.1')
port = int(os.environ.get('SELENIUM_PORT', 4444))
if not http.check_server(host, port, retries=1):
if 'SELENIUM_JAR' not in os.environ:
return False
else:
jar = os.environ['SELENIUM_JAR']
p = subprocess.Popen(['java', '-jar', jar])
os.environ['SELENIUM_PID'] = str(p.pid)
return http.check_server(host, port)
return True
def test_no_server(self):
host, port = http.get_free_port()
self.assertEqual(0, http.check_server(host, port, retries=2))
def test_no_server(self):
host, port = http.get_free_port()
self.assertEqual(0, http.check_server(host, port, retries=2))
def _run_server(self, filename):
"""Run a simple server in a separate thread"""
ip, port = http.get_free_port()
def run():
FileHandler.filename = filename
server = BaseHTTPServer.HTTPServer((ip, port), FileHandler)
server.handle_request()
thread = threading.Thread(target=run)
thread.start()
return 'http://%s:%s/' % (ip, port)