How to use the webtest.http function in WebTest

To help you get started, we’ve selected a few WebTest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pylons / webtest / tests / test_app.py View on Github external
def setUp(self):
        self.s = http.StopableWSGIServer.create(debug_app)
        self.s.wait()
github Pylons / webtest / webtest / sel.py View on Github external
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
github Pylons / webtest / tests / test_http.py View on Github external
def setUp(self):
        self.s = http.StopableWSGIServer.create(debug_app)
github Pylons / webtest / webtest / sel.py View on Github external
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
github Pylons / webtest / webtest / sel.py View on Github external
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
github Pylons / webtest / tests / test_http.py View on Github external
def test_no_server(self):
        host, port = http.get_free_port()
        self.assertEqual(0, http.check_server(host, port, retries=2))
github Pylons / webtest / tests / test_http.py View on Github external
def test_no_server(self):
        host, port = http.get_free_port()
        self.assertEqual(0, http.check_server(host, port, retries=2))
github Pylons / webtest / webtest / sel.py View on Github external
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)