Skip to content

Commit

Permalink
Add test of running the server
Browse files Browse the repository at this point in the history
  • Loading branch information
witchard committed Sep 21, 2017
1 parent 4010ec9 commit 12929fe
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_serve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import unittest
import asyncio
import io
import multiprocessing
import urllib.request
import time

import grole

def simple_server():
app = grole.Grole()

@app.route('/')
def hello(env, req):
return 'Hello, World!'

app.run()


class TestServe(unittest.TestCase):

def test_simple(self):
p = multiprocessing.Process(target=simple_server)
p.start()
time.sleep(0.1)
with urllib.request.urlopen('http://localhost:1234') as response:
html = response.read()
self.assertEqual(html, b'Hello, World!')
p.terminate()

0 comments on commit 12929fe

Please sign in to comment.