Skip to content

Duplicated test runs when using LiveServerTestCase with use_reloader = True #33

@alisaifee

Description

@alisaifee

This isn't a bug in LiveServerTestCase itself but with running the flask application using wekzeug with multiprocessing when the use_reloader option set to true. It can be reproduced with the following snippet

import unittest
import multiprocessing
import flask
import time
import random

class FlaskAppMultiProcTest(unittest.TestCase):
    def runTest(self):
        app = flask.Flask(__name__)
        proc = multiprocessing.Process(target=app.run
                , kwargs = {"use_reloader":True})
        proc.start()
        time.sleep(1)
        proc.terminate()

if __name__ == "__main__":
    unittest.main()
  • Changing use_reloader to False results in single execution.
  • Running the above sample will show output from the double execution.
  • Replacing unittest.main() with FlaskAppMultiProcTest().runTest() will also result in double execution.
  • Running the test with nosetests also results in double execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions