Skip to content

Instantly share code, notes, and snippets.

@jinhoyoo
Last active December 21, 2020 20:50
Show Gist options
  • Save jinhoyoo/4412e7a87fdecf04200d to your computer and use it in GitHub Desktop.
Save jinhoyoo/4412e7a87fdecf04200d to your computer and use it in GitHub Desktop.
flask-testing: LiveServerTestCase example
import urllib2
from datalibs import app
import unittest
from flask import Flask
from flask.ext.testing import LiveServerTestCase
class MyTest(LiveServerTestCase):
def create_app(self):
app.config['TESTING'] = True
# Default port is 5000
app.config['LIVESERVER_PORT'] = 8943
return app
def test_server_is_up_and_running(self):
response = urllib2.urlopen(self.get_server_url()+"/login")
self.assertEqual(response.code, 200)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment