Skip to content Skip to sidebar Skip to footer

Getting A "can't Pickle Local Object 'liveservertestcase'" Error When Trying To Use Liveservertestcase To Test Flask App

I am getting the error mentioned in the title once trying to run a unittest on my Flask app using LiveServerTestCase from flask_testing. This is my test file: from app import creat

Solution 1:

I also ran into this issue and wanted to post so others might have somewhere to start and not need to sleuth as deep as me--

I found a partial answer here that helped me figure out what was happening at least: https://github.com/pytest-dev/pytest-flask/issues/104

apparently on OSX you need to run the following code to switch the multiprocessing style to fork instead of spawn which is the new default and incompatible with pickle:

multiprocessing.set_start_method("fork")

I'm developing on Windows, so from what I could tell I'm kinda out of luck- but I have another test server running CentOs so for proof of concept I tried running the tests there and it worked without issues!

lastly: On another issue thread I found the following that might help and Windows people make a workaround: https://github.com/pytest-dev/pytest-flask/issues/54

Solution 2:

Can't really identify what could be the cause. But sorry to ask, have you checked the flask version you are using and it's current compatibility with your python version.

Post a Comment for "Getting A "can't Pickle Local Object 'liveservertestcase'" Error When Trying To Use Liveservertestcase To Test Flask App"