Home New Trending Search
About Privacy Terms
#
#Pytest
Posts tagged #Pytest on Bluesky
Preview
GitHub - einenlum/pytest-elegant: A pytest plugin to make it look beautiful - Pest inspired A pytest plugin to make it look beautiful - Pest inspired - einenlum/pytest-elegant

A #pytest plugin to make the output look like #pest 's one: github.com/einenlum/pyt...

#PHP #Python

1 0 0 0
Preview
GitHub - localizethedocs/pytest-docs-l10n: Localization of Pytest Documentation Localization of Pytest Documentation. Contribute to localizethedocs/pytest-docs-l10n development by creating an account on GitHub.

🎉 pytest-docs-l10n is published!

🚀 Preview:

projects.localizethedocs.org/pytest-docs-...

🌐 Crowdin:

localizethedocs.crowdin.com/pytest-docs-...

🐙 GitHub:

github.com/localizethed...

#Crowdin #GitHub #Sphinx #Python #Pytest #Testing

0 0 0 0
Preview
Configuration You can use configuration files to change the way pytest runs. If you repeatedly use certain options in your tests, such as--verbose or--strict-markers, you can store them in a configuration file s...

… and now we have also moved the pytest configuration to the pyproject.toml file: python-basics-tutorial.readthedocs.io/en/latest/te...
#Python #Testing #pytest

2 1 0 0
Post image

api-mocker v0.5.1 just hit ~9 k downloads on PyPI - great momentum for a simple, powerful API mocking tool in Python testing. If you mock multiple endpoints in pytest and want cleaner, maintainable tests, give it a spin.
pip install api-mocker
#Python #pytest #APITesting #DevTools #opensource

2 0 0 0
Pytest parameter functions Pytest’s parametrize is a great feature for writing tests without repeating yourself needlessly. (If you haven’t seen it before, read Starting with pytest’s parametrize first). When the data gets complex, it can help to use functions to build the data parameters. I’ve been working on a project involving multi-line data, and the parameterized test data was getting awkward to create and maintain. I created helper functions to make it nicer. The actual project is a bit gnarly, so I’ll use a simpler example to demonstrate. Here’s a function that takes a multi-line string and returns two numbers, the lengths of the shortest and longest non-blank lines: > > def non_blanks(text: str) -> tuple[int, int]: > > >     """Stats of non-blank lines: shortest and longest lengths.""" > > >     lengths = [len(ln) for ln in text.splitlines() if ln] > > >     return min(lengths), max(lengths) > > > We can test it with a simple parameterized test with two test cases: > > import pytest > > > from non_blanks import non_blanks > > > > > > @pytest.mark.parametrize( > > >     "text, short, long", > > >     [ > > >         ("abcde\na\nabc\n", 1, 5), > > >         ("""\ > > > A long line > > > The next line is blank: > > > > > > Short. > > > Much much longer line, more than anyone thought. > > > """, 6, 48), > > >     ] > > > ) > > > def test_non_blanks(text, short, long): > > >     assert non_blanks(text) == (short, long) > > > I really dislike how the multi-line string breaks the indentation flow, so I wrap strings like that in textwrap.dedent: > > @pytest.mark.parametrize( > > >     "text, short, long", > > >     [ > > >         ("abcde\na\nabc\n", 1, 5), > > >         (textwrap.dedent("""\ > > >             A long line > > >             The next line is blank: > > > > > >             Short. > > >             Much much longer line, more than anyone thought. > > >             """), > > >         6, 48), > > >     ] > > > ) > > > (For brevity, this and following examples only show the parametrize decorator, the test function itself stays the same.) This looks nicer, but I have to remember to use dedent, which adds a little bit of visual clutter. I also need to remember that first backslash so that the string won’t start with a newline. As the test data gets more elaborate, I might not want to have it all inline in the decorator. I’d like to have some of the large data in its own file: > > @pytest.mark.parametrize( > > >     "text, short, long", > > >     [ > > >         ("abcde\na\nabc\n", 1, 5), > > >         (textwrap.dedent("""\ > > >             A long line > > >             The next line is blank: > > > > > >             Short. > > >             Much much longer line, more than anyone thought. > > >             """), > > >         6, 48), > > >         (Path("gettysburg.txt").read_text(), 18, 80), > > >     ] > > > ) > > > Now things are getting complicated. Here’s where a function can help us. Each test case needs a string and three numbers. The string is sometimes provided explicitly, sometimes read from a file. We can use a function to create the correct data for each case from its most convenient form. We’ll take a string and use it as either a file name or literal data. We’ll deal with the initial newline, and dedent the multi-line strings: > > def nb_case(text, short, long): > > >     """Create data for test_non_blanks.""" > > >     if "\n" in text: > > >         # Multi-line string: it's actual data. > > >         if text[0] == "\n":     # Remove a first newline > > >             text = text[1:] > > >         text = textwrap.dedent(text) > > >     else: > > >         # One-line string: it's a file name. > > >         text = Path(text).read_text() > > >     return (text, short, long) > > > Now the test data is more direct: > > @pytest.mark.parametrize( > > >     "text, short, long", > > >     [ > > >         nb_case("abcde\na\nabc\n", 1, 5), > > >         nb_case(""" > > >             A long line > > >             The next line is blank: > > > > > >             Short. > > >             Much much longer line, more than anyone thought. > > >             """, > > >             6, 48), > > >         nb_case("gettysburg.txt", 18, 80), > > >     ] > > > ) > > > One nice thing about parameterized tests is that pytest creates a distinct id for each one. The helps with reporting failures and with selecting tests to run. But the id is made from the test data. Here, our last test case has an id using the entire Gettysburg Address, over 1500 characters. It was very short for a speech, but it’s very long for an id! This is what the pytest output looks like with our current ids: > > test_non_blank.py::test_non_blanks[abcde\na\nabc\n-1-5] PASSED > > > test_non_blank.py::test_non_blanks[A long line\nThe next line is blank:\n\nShort.\nMuch much longer line, more than anyone thought.\n-6-48] PASSED > > > test_non_blank.py::test_non_blanks[Four score and seven years ago our fathers brought forth on this continent, a\nnew nation, conceived in Liberty, and dedicated to the proposition that all men\nare created equal.\n\nNow we are engaged in a great civil war, testing whether that nation, or any\nnation so conceived and so dedicated, can long endure. We are met on a great\nbattle-field of that war. We have come to dedicate a portion of that field, as a\nfinal resting place for those who here gave their lives that that nation might\nlive. It is altogether fitting and proper that we should do this.\n\nBut, in a larger sense, we can not dedicate \u2013 we can not consecrate we can not\nhallow \u2013 this ground. The brave men, living and dead, who struggled here, have\nconsecrated it far above our poor power to add or detract. The world will little\nnote, nor long remember what we say here, but it can never forget what they did\nhere. It is for us the living, rather, to be dedicated here to the unfinished\nwork which they who fought here have thus far so nobly advanced. It is rather\nfor us to be here dedicated to the great task remaining before us that from\nthese honored dead we take increased devotion to that cause for which they gave\nthe last full measure of devotion \u2013 that we here highly resolve that these dead\nshall not have died in vain that this nation, under God, shall have a new birth\nof freedom \u2013 and that government of the people, by the people, for the people,\nshall not perish from the earth.\n-18-80] PASSED > > > Even that first shortest test has an awkward and hard to use test name. For more control over the test data, instead of creating tuples to use as test cases, you can use pytest.param to create the internal parameters object that pytest needs. Each of these can have an explicit id assigned. Pytest will still assign an id if you don’t provide one. Here’s an updated `nb_case()` function using pytest.param: > > def nb_case(text, short, long, id=None): > > >     if "\n" in text: > > >         # Multi-line string: it's actual data. > > >         if text[0] == "\n":     # Remove a first newline > > >             text = text[1:] > > >         text = textwrap.dedent(text) > > >     else: > > >         # One-line string: it's a file name. > > >         id = id or text > > >         text = Path(text).read_text() > > >     return pytest.param(text, short, long, id=id) > > > Now we can provide ids for test cases. The ones reading from a file will use the file name as the id: > > @pytest.mark.parametrize( > > >     "text, short, long", > > >     [ > > >         nb_case("abcde\na\nabc\n", 1, 5, id="little"), > > >         nb_case(""" > > >             A long line > > >             The next line is blank: > > > > > >             Short. > > >             Much much longer line, more than anyone thought. > > >             """, > > >             6, 48, id="four"), > > >         nb_case("gettysburg.txt", 18, 80), > > >     ] > > > ) > > > Now our tests have useful ids: > > test_non_blank.py::test_non_blanks[little] PASSED > > > test_non_blank.py::test_non_blanks[four] PASSED > > > test_non_blank.py::test_non_blanks[gettysburg.txt] PASSED > > > The exact details of my `case()` function aren’t important here. Your tests will need different helpers, and you might make different decisions about what to do for these tests. But a function like this lets you write your complex test cases in the way you like best to make your tests as concise, expressive and readable as you want.

Here's a description of some nice features I didn't know about in #PyTest's parameterize() decorator. My favourite is how to avoid really long names for test cases.

nedbatchelder.com/blog/202602/pytest_param...

#python

1 0 0 0
Post image

No hay mayor satisfacción que cuando implementas algo en tu código, haces #pytest y te pasa a la primera con todo en verde 😌
.
.
.
#programming #code #python #FastAPI

1 0 0 0
Post image

Параллелизация pytest: от xdist до Kubernetes Тесты — это хорошо. Медленные тесты — это CI на 40 минут и разработчики, ко...

#python #параллелизация #тестов #pytest #изоляция #фикстур #flaky-тесты

Origin | Interest | Match

0 0 0 0
Preview
pytest-html-plus — Your Default Pytest Reporter Why another Pytest HTML reporter? If you’ve been running Pytest for a while, chances are...

pytest-html-plus — Your Default Pytest Reporter Why another Pytest HTML reporter? If you’ve been running Pytest for a while, chances are you’ve used pytest-html. It works. It’s stable. It d...

#testing #python #pytest #programming

Origin | Interest | Match

2 0 0 0
Video thumbnail

After 4 months imprisoned in the Bugfix & Boring‑Feature Mines,
I have finally escaped…
and I return bearing #pytest plugin for #ttkode.

New year, new me, same chaotic commits.

github.com/ceccopierangiolieugenio/pyTermTk

#pyTermTk #TUI #Python #Linux #terminal

0 0 0 0
screenshot avec sortie pytest, 54 tests, un seul ne passe pas

screenshot avec sortie pytest, 54 tests, un seul ne passe pas

let's call it a day
#pytest

0 0 0 0
Preview
Platform Dependent Python Coverage Test With Tox Learn how to run platform dependent Python coverage tests with tox, using env factors, platform markers, and coverage configuration to keep your test matrix clean and reliable.

Platform Dependent Python Coverage Test With Tox Testing Cross‑Platform Python Code Without Losing Your Mind Modern Python projects rarely run on a.... @cosmicmeta.ai #PyTest

https://u2m.io/PQdPoKH3

1 0 0 0
Video thumbnail

Ooohh noooo😭😭😭
.
#programming #python #pytest #vscode #error

1 0 0 0
Post image

Ever wondered what makes #pytest so powerful? 🧠

This #PyTexasConference2025 talk breaks it down—by building a #python test framework from scratch!

Discover the “why” behind runners, assertions & structure.

🎥 Watch the replay and master testing from the inside out!

www.pytexas.org/2025/schedul...

1 0 0 0
Preview
pytest pytest is an alternative to Python’s Unittest module that simplifies testing even further. pytest automatically recognises tests based on filenames and functions that start with test_, while unitte...

We have updated the section on pytest with many exciting use cases
* on command line options
* on generating markers
* and on parameterising exceptions
python-basics-tutorial.readthedocs.io/en/latest/te...
#Python #Testing #pytest

4 2 0 0
Preview
Optimizing Your Tests with Pytest Scopes Ever wondered why your Pytest suite takes ages to run? The secret often lies in a powerful but misunderstood feature: fixture scopes. We break down the crucial trade-off between perfect test isolation...

Stop writing slow tests. This guide unlocks the power of Pytest fixture scopes to dramatically speed up your test suite. We break down the crucial trade-off between perfect test isolation and performance.
#python #test #performance #pytest #LearnToCode
hevalhazalkurt.com/blog/optimiz...

1 0 0 0
Original post on social.coop

Mildly amused/annoyed that #pytest (in 9.0, out recently) finally got around to reinstating internal-to-test reporting fan-out: docs.pytest.org/en/stable/how-to/subtest...

I remember that they used to offer a Nose-like `yield` option for this, and was extremely salty when […]

0 0 0 0
Post image

What’s your go-to testing setup for Django projects?

🧪 #pytest leads testing in Django (39%), with #unittest close behind (33%).
That comes as no surprise – both dominate throughout the Python ecosystem.

Learn more in the State of Django 2025: https://jb.gg/blizwg

0 0 0 0
Original post on untrusted.website

This last issue has been somewhat educational in terms of my over reliance on the uv lockfile, and so it caused me to change a few things in the development environment.

1) I added a CI job that runs uv sync and the test suite with `--resolution lowest-direct`, which ensure my test suite matrix […]

1 0 0 0
Preview
GitHub - pytest-dev/pytest-describe: Describe-style plugin for the pytest framework Describe-style plugin for the pytest framework. Contribute to pytest-dev/pytest-describe development by creating an account on GitHub.

pytest-describe 3.0 is out - this pytest plugin allows you to nest pytest functions in describe blocks #python #pytest #testing github.com/pytest-dev/p...

1 0 0 0
Client Challenge

Mocket is out in the wild, with a version compatible with Python 3.14.
Enjoy testing your `asyncio` code!

#python #testing #mocket #socket #mocking #tdd #pytest #testing

pypi.org/project/mock...

2 0 1 0
Preview
GitHub - llaumgui/seedboxsync-front: Frontend for SeedboxSync, the Script for sync operations between your NAS and your seedbox. Frontend for SeedboxSync, the Script for sync operations between your NAS and your seedbox. - llaumgui/seedboxsync-front

Quelques screenshots de SeedboxSyncFront dans le readme...
On frôle les 80% de couverture de test 😀. J'arrive au bout de ce qu'il est possible de faire sans modifier le CLI. Des évolutions arrivent donc 😃.

github.com/llaumgui/see...

#python #flask #pytest #peewee

0 0 0 0
Preview
Databases are a Fad News and announcements from the Python community for the week of Sep 29th, 2025

🎙️ Python Bytes 451: Databases are a Fad
with @mkennedy.codes and @brianokken.bsky.social
pythonbytes.fm/episodes/sho...
#Python #pytest #testing #postgresql #pyrefly

6 3 1 0

I think I found why Codecov was not respecting the ignored lines from coverage.py: github.com/codecov/code.... Using #pragma: no cover for now works! #testing #pytest #python #coverage #programming #opensource

1 0 0 0
Preview
refactore(all): switch to pytest by guillaume-chervet · Pull Request #46 · guillaume-chervet/MLOpsPython Contribute to guillaume-chervet/MLOpsPython development by creating an account on GitHub.

Migré tout MLOpsPython de unittest à pytest en 10 min.
Mon astuce : un script Python qui génère un aperçu ciblé du code à donner à l’IA pour rester concentré sur l’essentiel.

PR : github.com/guillaume-ch...
Script : github.com/guillaume-ch...

#Python #pytest #MLOps #AI

0 0 0 0
googletest - Rust A rich test assertion library for Rust.

I used to think Rust testing was far behind Python with pytest, but that’s not really the case. There's a googletest crate that fixes so many pain points: clearer failure messages, test fixtures, approx comparisons for floats, and more.

docs.rs/googletest/l...

#rust #googletest #python #pytest

2 0 1 0

My next open in-depth #pytest trainings:

🇨🇭 October 29th to 31st, Zurich, Switzerland, with letsboot.ch: www.letsboot.ch/kurs/pytest
🇩🇪 🌍 March 3rd to 5th, Leipzig, Germany & Remote, with Python Academy: python-academy.com/courses/pyth...

#Python

3 1 0 0
Preview
Platform Dependent Python Coverage Test with Tox Learn how to achieve platform-dependent Python coverage testing with Tox. Discover best practices for cross-platform code quality automation, setup guides, and pitfalls to avoid. Master Tox to boost your software's reliability.

Platform Dependent Python Coverage Test with Tox Testing code across different platforms ensures robust Python development, particularly in dynamic environments operating on.... @cosmicmeta.ai #PyTest

https://u2m.io/oXhAVv0k

0 0 0 0
Preview
Platform Dependent Python Coverage Test with Tox Learn how to achieve platform-dependent Python coverage testing with Tox. Discover best practices for cross-platform code quality automation, setup guides, and pitfalls to avoid. Master Tox to boost your software's reliability.

Platform Dependent Python Coverage Test with Tox Testing code across different platforms ensures robust Python development, particularly in dynamic environments operating on.... @cosmicmeta.ai #PyTest

https://u2m.io/oXhAVv0k

0 0 0 0