Hacker News new | ask | show | jobs
by grammarxcore 2355 days ago
Comparing the code samples, it looks like it's easier to spin up testing with Httpx than Flask, but that's a superficial conclusion. I don't have experience with Httpx so take this with a grain of salt. Based on the comparison, I'm going to play with Httpx for testing the next time I use Flask because the simplicity looks rad.

Based on similar experience with other tools, that possibly means that Httpx is great for simple testing but if you need to go deep it's better to use the framework provided. That's an assumption, though, so I'd love to hear more from others.

1 comments

Flask’s sample code is doing a bunch of things like spinning up db and stuff and setting up a pytest fixture, so it’s not a fair comparison. You can replace

  with httpx.Client(app=app) as client:
      ...

in the httpx sample code with

  with app.test_client() as client:
      ...
for flask’s builtin test client and the rest is basically the same. Now that’s a fair comparison and neither is simpler than the other.

I guess one advantage of httpx is that developers might generally be more familiar with the requests response object API than the werkzeug response object API.