TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What is your preferred Python 3 testing framework?

84 pointsby eshlomoover 7 years ago

12 comments

bpicoloover 7 years ago
pytest:<p><a href="https:&#x2F;&#x2F;docs.pytest.org&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.pytest.org&#x2F;en&#x2F;latest&#x2F;</a><p>The dependency injection for fixtures is somewhat of a magical entity, but overall I&#x27;ve found it&#x27;s the most efficient way to hammer out good tests on the standard unit&#x2F;integration test spectrum. The default mode of operation doesn&#x27;t even require importing pytest: Just write files named ending with `_test.py`, functions starting with `test`, and bare bones assertions. `yield_fixture` works well with the typical mock-and-assert-on python test pattern.<p>Plenty of plugins out there for more exotic features, like asyncio, parallelization (though test parallelization tends to be much more problematic beyond &quot;run tests at the same time&quot;), output to &lt;format&gt;, etc too.
评论 #15630342 未加载
评论 #15629328 未加载
评论 #15630316 未加载
评论 #15629268 未加载
评论 #15629343 未加载
评论 #15630850 未加载
0x54MUR41over 7 years ago
The company I work for uses standard unittest [0] library from Python. This library helps you to test defined functions in your Python program. For each defined function, you can set different cases to test (positive and negative cases). We also use coverage [1] to see code coverage and report. Report is usually reported to HTML because we can check the missing part of code (the flow of our logic program).<p>[0]: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;unittest.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;unittest.html</a><p>[1]: <a href="https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;coverage" rel="nofollow">https:&#x2F;&#x2F;pypi.python.org&#x2F;pypi&#x2F;coverage</a>
评论 #15631203 未加载
评论 #15629480 未加载
kissgyorgyover 7 years ago
How is this a question? Pytest is so much better and more used than any other testing framework you don&#x27;t even have to think about it.
dbcurtisover 7 years ago
currently using good old unittest but with the addition of hypothesis. hypothesis is a real productivity booster.
评论 #15629595 未加载
Singletonedover 7 years ago
Anything but pytest is good.<p>Pytest is full of magic and can be horrendous for a newcomer to your team. You can&#x27;t work out what is happening just by reading the tests, you have to know how pytest works.<p>Also, when something breaks in pytest, all the magic means that it can be very hard to work out what is happening.
hprotagonistover 7 years ago
pytest and hypothesis.
评论 #15629592 未加载
luordover 7 years ago
Pytest, once I understood how the fixture system works, I never looked back. I wish JavaScript had something similar
__sover 7 years ago
import unittest<p>Used for CI in <a href="https:&#x2F;&#x2F;github.com&#x2F;serprex&#x2F;aespython" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;serprex&#x2F;aespython</a>
ak217over 7 years ago
unittest with <a href="https:&#x2F;&#x2F;github.com&#x2F;kislyuk&#x2F;ensure" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kislyuk&#x2F;ensure</a>
orfover 7 years ago
Pytest all the way.
sidllsover 7 years ago
The built-in unittest library does the job well.
ri0tover 7 years ago
tox with py.test