Last chance to grab “Python Testing with pytest” at 40% off with code SPRING2025.
Expires June 3, 2025.
https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition/
#python #pytest
Isn't it awesome that a test failure in #Twisted (which probably indicates a real problem with the code) occurs only if you have additionally installed #Trio, #PyTest and Py? Like, my understanding is that Trio gets imported by Twisted, and via automagic optional import chain Trio → PyTest → Py, a bug gets triggered.
https://github.com/twisted/twisted/issues/12458#issuecomment-2907855880
I'm adding resources for future reading for mine and Marie's #Python #packaging tutorial for #PyConUS, and I realised that I don't know any good #pytest tutorials for beginners. Does anyone have any reccommendations?
I just decided to piggy back the @pragprog sale and offer 40% off of courses at https://courses.pythontest.com with code 2025TESTING now through April 22 #python #pytest https://fosstodon.org/@brianokken/114344124201148334
Python Testing with pytest, 2nd edition
40% Off – This Week Only!
Code: 2025testing at checkout
https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition/
#Python #pytest
@gagliardi_vale The #pytest documentation is also pretty decent, come to think of it: https://docs.pytest.org/en/stable/
Decentralizers, attention! :)
Last #deltachat releases introduced stable #p2p group membership not found in any other messenger. Members can add/remove peers also while being offline, and when everything comes online again, everyone has the same consistent membership view. We formalized and ran a simulation model using #TLA+ (invented by Leslie Lamport of vector clock fame):
https://github.com/chatmail/models/tree/main/group-membership
and a complementary #pytest model with more corner cases tested here:
https://github.com/chatmail/models/blob/main/gmc/test_gmc.py
Dear @ThePSF ...
having been engaged with #Python through co-creating #pytest #pypy, giving talks and trainings i appreciate that the PSF has long been a champion of diversity and inclusion! Are you aware that these days many non-USians are canceling their US travels? The German foreign ministry warns about travel to the US if you are pregnant or don't have your passport carrying a birth gender marker, then this: https://www.kpbs.org/news/border-immigration/2025/02/28/german-tourist-held-indefinitely-in-san-diego-area-immigrant-detention-facility
Maybe better update the #Pycon webpage accordingly?
@WillyECoyote69 Definitely pytest, if you ask me. pytest is by far my favorite testing framework out of all the ones I've used across different programming languages.
Unless using things outside the standard library is a huge burden for you, of course, but that's rarely the case.
️ Nouvel article sur le blog !
Aujourd'hui je vous fais un petit retour d'expérience sur la manière dont j'ai implémenté des tests sur FLOZz Daily Mix (mon générateur de playlist), à l'aide d'une instance #Nextcloud dans #Docker, de #Pytest, de #Nox et de #GitHub Actions.
L'article aborde à la fois la démarche et la technique mais devrait rester relativement accessible à tous les curieux ! ️
pytest-check 2.5.0 released.
It's gotten some recent attention from the community and I'm very grateful.
Thanks mfulgo for adding type hints. Super awesome.
And thanks to taylermulligan for fixing a longtime issue that we weren't respecting --runxfail.
https://github.com/okken/pytest-check
#Python #pytest
New blog post!
This time it's my first post about slightly advanced programming in Python. I talk about using the dependency injection design pattern to separate business logic from I/O calls to have cleaner code and simpler tests.
Well, actually the topic is more generic and can be applied to any programming language, but here I use Python as an example.
Anyway, here it is!
pytest-mock : Mocking in pytest
Test & Code episode
https://testandcode.com/episodes/pytest-mock
- Why the pytest-mock plugin is awesome
- Mocking, patching, monkeypatching
- Mocks, fakes, stubs and spies
- Why do we need these for testing
- pytest-mock as a curated wrapper around unittest.mock
#Python #pytest #mock
Hey, #python / #django people: I dimly recall a tool that uses #coverage data to only run #pytest tests that impact changed lines of code, or changed methods/logical blocks of code.
Like: "User.get_display_name was changed, and coverage data shows that these 15 tests test this method directly or indirectly, so only run those"
ring any bells? I found partialtesting (dead) and pytest-watch (spams *such* an amount of irrelevant messages in my project it's unusable, see https://github.com/joeyespo/pytest-watch/issues/115)
If your program is leaking memory (or CUDA memory, or file descriptors, or really any limited resource), one way to identify the problem is to use your test suite to identify specific problem APIs. I demonstrate this using pytest fixtures:
https://pythonspeed.com/articles/identifying-resource-leaks-with-pytest/
Test & Code: Let’s kick off Season 2, all about pytest plugins
https://testandcode.com/episodes/pytest-plugins
#Python #pytest
This might be obvious but just in case: if #pytest reports a test failures like:
…
=========================== short test summary info ============================
FAILED tests/component/deb/test_import_orig.py::TestImportOrig::test_uscan - AssertionError: assert 1 == 0
+ …whatever failed …
FAILED another/failure
Then you can run that single test by invoking pytest with the bits after FAILED and before -, e.g. here:
pytest tests/component/deb/test_import_orig.py::TestImportOrig::test_uscan
One thing I enjoy about #pytest is packages can provide fixtures for it and it just... finds them for me.
I love using #factoryboy with pytest, and it brings #faker with it.
And faker offers a pytest fixture.
It all just... works!