Ever wondered how to parametrize exception testing in PyTest?
Try this:
https://borutzki.github.io/2026/01/15/how-to-parametrize-exception-testing-in-pytest.html
#DailyPythonista #python #programming #Pytest #TDD #unittest
Ever wondered how to parametrize exception testing in PyTest?
Try this:
https://borutzki.github.io/2026/01/15/how-to-parametrize-exception-testing-in-pytest.html
#DailyPythonista #python #programming #Pytest #TDD #unittest
https://pytest-watcher.readthedocs.io/ aka https://github.com/olzhasar/pytest-watcher does exactly what I want; sit parked in its own terminal beside an ide and continually re-run tests whenever something changes.
🐍 This #pytest 101 talk explains what automated tests are and how to get started with pytest for your #Python projects. https://www.youtube.com/watch?v=etosV2IWBF0
When writing asserts in tests, do you put the actual first or the expected?
The convention seems to be: actual first. But, annoyingly, I need to rearrange them to check if an expected is _in_ an actual which I tend to do a fair amount.
Maybe that's a testing code smell. Or maybe I'm just overthinking this. 😅
Running the whole test suite (~135 tests) for django-new takes around 20 seconds. Trying out the new to me library, pyfakefs: https://pytest-pyfakefs.readthedocs.io.
Example test results:
- Using `tmp_path`: 0.95s
- Using `fs`: 0.17s
I'll take a 5x speed-up if I don't run into any gotchas!
Here’s what I'm following to replace tmp_path in #pytest: https://pytest-pyfakefs.readthedocs.io/en/latest/troubleshooting.html#a-replacement-for-the-tmp-path-fixture.
🔧 Pytest đẹp hơn với plugins! Cài pytest-sugar để thấy progress bar màu, pytest-rich cho console đa màu, pytest-clarity cải thiện diff, pytest‑cov báo coverage màu, pytest‑instafail hiển thị lỗi ngay, pytest‑tldr tóm tắt nhanh, plus pytest‑html/md cho báo cáo CI. Kết hợp chúng → log test rõ ràng, nhanh, dễ đọc. #pytest #Python #Testing #LậpTrình #KiểmThử #DevTools
Bạn thay đổi một dòng code nhỏ, và mọi thứ sụp đổ? Đừng lo, **pytest** giúp bạn kiểm soát! Với cú pháp đơn giản, chỉ cần viết hàm bắt đầu bằng `test_` và dùng `assert`, pytest tự động tìm và chạy test. Cài đặt: `pip install pytest`, viết test cho hàm, rồi chạy `pytest`. Dễ hiểu, ít cấu hình, báo lỗi rõ ràng. Bắt đầu ngay hôm nay để code tự tin hơn!
#pytest #testing #Python #lập_trình #kiểm_thử #mã_nguồn #dev #programming #unittest #automation
📽️ Ah, the riveting saga of *detecting* video codecs with #Python... because why upgrade your iPhone when you can waste hours #scripting instead? 😂 Just imagine the thrill of running #pytest on your media library while the rest of us simply watch videos. 🎞️
https://alexwlchan.net/2025/detecting-av1-videos/ #detectingcodecs #videolibrary #humor #HackerNews #ngated
Worked on some more #Gentoo global #jobserver goodies today.
Firstly, Portage jobserver support patch: https://github.com/gentoo/portage/pull/1528. It's not yet perfect, but it seems to work. If enabled via FEATURES=jobserver-token, it causes emerge to acquire a job token for every job it starts, therefore:
1. emerge won't start more jobs than the jobserver specifies. For example, `steve -j12` will cap emerge at 12 jobs, even if you specify --jobs=16. However, lower cap for emerge will be respected, so you can leave a bunch of job tokens free for other processes to use.
2. emerge will share the job pool with other jobserver-enabled software such as GNU make or Ninja. When emerge is using up all 12 job tokens, all builders inside it will run serial. When it's running 6 jobs, all builders will be able to start up to 6 extra jobs, etc. Ideally, no more than 12 active jobs will be running at a time over the system.
3. Jobserver-enabled software will now correctly respect jobserver job count. When running with externally-provided jobserver, these tools assumed that the jobserver already acquired one token for them, and therefore ran one extra job without a token; say, 13 jobs for a single emerge process. Now the token is actually acquired, so the accounts will match.
Secondly, I've packaged dev-python/pytest-jobserver with a bunch of fixes to make it behave correctly and support Gentoo jobserver. We're not integrating it with the eclasses yet, but you can install it and force-enabled via EPYTEST_FLAGS="-p jobserver". With it, pytest-xdist will acquire job tokens while running tests, and therefore parallel #PyTest jobs will also be counted towards total job count.
Again, it's not a perfect solution, but it works reasonably. The plugin still starts -n jobs as specified by the arguments, but it acquired job tokens prior to executing every test, therefore delaying actual testing until tokens are available. It doesn't seem to cause noticeable overhead either.
Một kỹ sư QA thất nghiệp đang phát triển công cụ tạo test tự động. Anh ấy đề nghị viết miễn phí các bài test Pytest/Jest thủ công cho logic cốt lõi (không phải UI) từ kho mã nguồn GitHub của bạn. Mục đích là để hiểu các trường hợp biên mà dev quan tâm, giúp cải thiện công cụ của mình. Cơ hội tốt để có test chất lượng!
#QA #Testing #Pytest #Jest #SideProject #FreeService #KiểmThử #PhátTriểnPhầnMềm #DịchVụMiễnPhí
https://www.reddit.com/r/SideProject/comments/1peivny/im_an_unemployed_qa_engineer_b
Một kỹ sư QA thất nghiệp đang xây dựng công cụ tạo test tự động. Anh ấy đề nghị viết miễn phí các bài kiểm thử Pytest/Jest cho logic cốt lõi trong repo GitHub của bạn để hiểu rõ hơn về nhu cầu thực tế của nhà phát triển. Cơ hội tốt để có test miễn phí và giúp một side project!
#QA #Testing #Pytest #Jest #SideProject #FreeTests #KiểmThử #PhátTriểnPhầnMềm #DựÁnPhụ
https://www.reddit.com/r/SideProject/comments/1peivny/im_an_unemployed_qa_engineer_building_a_test/
"Disable network requests when running Pytest"
https://blog.pecar.me/disable-network-requets-when-running-pytest
Как ускорить автотесты на Python в Pytest в 8,5 раз
Меня зовут Анатолий Бобунов, я работаю SDET в компании EXANTE. Однажды я пришел на проект, на котором выполнение некоторых тест-сьютов занимало больше часа, настолько медленно, что запускать их на каждый merge request (MR) было просто нереально. Мы хотели запускать автотесты на каждый коммит в MR, но с такой скоростью это было невозможно. В результате мне удалось, за счёт серии небольших, но точных изменений добиться 8,5-кратного ускорения - без переписывания тестов с нуля. В статье расскажу, какие проблемы у нас возникли и как мы их решали.
Completed my first ever #AdventOfCode challenges yesterday. Actually kinda fun, perhaps because I knew exactly where to begin than my default brute force approach. Did it in #Python, helped by #uv and #pytest. Will see if I either stick to it, and if I stick to Python (using it a lot on my team right now so good to hone those skills).
TIL setting `log_level` for #pytest shows those log messages when a test fails. https://docs.pytest.org/en/stable/reference/reference.html#confval-log_level #python