Open sularz-maciej opened 1 year ago
This looks good, thanks for sharing it. I think given the lack of interest from the Flask team in preserving features of the framework that worked before, such as the server shutdown and app.run() integration with the CLI, what you have done is probably the best option.
So I tried it with these changes and it worked
cls.server_thread = threading.Thread(
target=cls.app.run,
kwargs={
"host": cls.HOST,
"port": cls.PORT,
"debug": False,
"use_reloader": False,
"use_debugger": False,
},
daemon=True
)
cls.server_thread.join(2)
Thank you, @miguelgrinberg, for your invaluable help with Flask. We truly appreciate your guidance and expertise as our Flask Mentor. I hope you are doing well. I would also like to extend my gratitude to @sularz-maciej for your approach in assisting me.
Currently, I am facing two issues with the following approach:
os.kill(os.getpid(), signal.SIGINT)
Using this method terminates the process and ends all other tests.
Unfortunately, I am unable to determine if the other methods are running successfully. To provide more context, here is the relevant code snippet:.
# Destroy the database
db.drop_all()
db.session.remove()
# Remove the application context
cls.app_context.pop()
I would greatly appreciate any assistance you can provide in resolving this issue. If there are any suggestions or alternative approaches you could recommend, I would be grateful for your expertise.
Thank you once again for your valuable help.
Hi Miguel,
I'm just about to finish your book, absolutely love it. I've been following along as I read and noticed that the packages are quite outdated (as expected). I decided to code your app using the latest available packages and so far apart from some minor syntax differences it was smooth sailing. This was the case up until the 'End-to-End Testing with Selenium' (15d), it took me 2 days to make it work with
Selenium v4.7.2
andUnittest
and I just wanted to leave it here in case someone else runs into this problem as well as ask if this is the correct way to do it. It feels more like a hack to me rather than the actual solution so I would really appreciate your input.Below are the packages I'm using as well as my solution to the problem. By the way I'm also using
ChromeDriver 108.0.5359.71
I figured out the solution tanks to https://github.com/pallets/flask/issues/2776
requirements/common.txt
requirements/common.txt
main/views.py
config.py
tests/test_selenium.py