ref: Do not use test classes for tornado tests#292
Conversation
|
Haha, I know barely enough to be dangerous, but I don't think the AsyncHTTPTestCase requires any async code, it just supports it. The following code seems to work to trigger an exception in the test case, perhaps you see how you'd integrate the Sentry testing into that? @bdarnell (Tornado's maintainer) might have some pointers. Ben, Markus is looking for the best way to maintain Sentry's integration with Tornado, if you have any advice. |
|
I'm interested in using pytest fixtures for the tests as opposed to unittest classes, because injecting my existing pytest fixtures into AsyncHTTPTestCase-based tests is painful. Anyway, what i am doing now works well enough for me, just wondering if there's a better way.
I was talking about pytest-tornado and pytest-asyncio when I said that. I have nothing against async code even, but I just didn't get anything other than what I have right now to run. |
|
In general I recommend either fully embracing async (in this case using pytest-tornado or pytest-asyncio. It's not clear what obstacles you ran into there), or keeping it at arms length by running the tornado server on a separate thread (as, I assume, you are doing with the synchronous frameworks). What you have here looks like an awkward middle ground. I think it's also possible to make a more targeted test fixture for your use case that doesn't rely on AsyncHTTPTestCase. Something like this (I don't have much experience with pytest and I'm not sure how its fixtures work, but it's also not clear that they're necessary here):
|
|
Thanks for the reply, @bdarnell! Markus, I'm not at all familiar with these test frameworks, so I'm afraid I won't be much further help on this. |
@nickbaum you seem to know what you're doing. Can you recommend something to test Tornado apps with? This solution I have right now is working fine but it seems hard to maintain