I tried using the "Dynamic LiveServerTestCase port" feature as described in the docs. I am setting the LIVESERVER_PORT setting to 0 but the test server always falls back to flask default, port 5000. This failing python2 test case illustrates this:
from urllib2 import urlopen
from flask import Flask
from flask_testing import LiveServerTestCase
class MyTest(LiveServerTestCase):
def create_app(self):
app = Flask(__name__)
app.config['TESTING'] = True
# Default port is 5000
app.config['LIVESERVER_PORT'] = 0
# Default timeout is 5 seconds
app.config['LIVESERVER_TIMEOUT'] = 10
return app
def test_server_doesnt_use_flask_default_port(self):
self.assertNotEqual(self.get_server_url(), 'http://localhost:5000')
I tried using the "Dynamic LiveServerTestCase port" feature as described in the docs. I am setting the
LIVESERVER_PORT
setting to0
but the test server always falls back to flask default, port 5000. This failing python2 test case illustrates this: