summaryrefslogtreecommitdiff
path: root/cherrypy/test
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2018-06-16 10:35:12 -0400
committerGitHub <noreply@github.com>2018-06-16 10:35:12 -0400
commitac398794535dee6bb774fa3da3c469339febdd03 (patch)
tree9fffd3c6e31c576841291ea8c951b16fe1e25bc7 /cherrypy/test
parent1ec6fac5e3c64343414fd8cc4d40059516891c6c (diff)
parente7b8ad91dba231d6abe47c6c69dae87b535ad54b (diff)
downloadcherrypy-git-16.0.0.tar.gz
Merge pull request #1712 from cherrypy/bugfix/1377-fix-native-http-server-compatibilityv16.0.0
Fix native HTTP server compatibility
Diffstat (limited to 'cherrypy/test')
-rw-r--r--cherrypy/test/test_native.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/cherrypy/test/test_native.py b/cherrypy/test/test_native.py
new file mode 100644
index 00000000..caebc3f4
--- /dev/null
+++ b/cherrypy/test/test_native.py
@@ -0,0 +1,35 @@
+"""Test the native server."""
+
+import pytest
+from requests_toolbelt import sessions
+
+import cherrypy._cpnative_server
+
+
+pytestmark = pytest.mark.skipif(
+ 'sys.platform == "win32"',
+ reason='tests fail on Windows',
+)
+
+
+@pytest.fixture
+def cp_native_server(request):
+ """A native server."""
+ class Root(object):
+ @cherrypy.expose
+ def index(self):
+ return 'Hello World!'
+
+ cls = cherrypy._cpnative_server.CPHTTPServer
+ cherrypy.server.httpserver = cls(cherrypy.server)
+
+ cherrypy.tree.mount(Root(), '/')
+ cherrypy.engine.start()
+ request.addfinalizer(cherrypy.engine.stop)
+ url = 'http://localhost:{cherrypy.server.socket_port}'.format(**globals())
+ return sessions.BaseUrlSession(url)
+
+
+def test_basic_request(cp_native_server):
+ """A request to a native server should succeed."""
+ cp_native_server.get('/')