Last active
December 21, 2020 20:50
-
-
Save jinhoyoo/4412e7a87fdecf04200d to your computer and use it in GitHub Desktop.
flask-testing: LiveServerTestCase example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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