Pamela Fox · @pamelafox
2698 followers · 960 posts · Server fosstodon.org

Quick blog post: Mocking async package calls with

(using monkeypatch and asynchronous generators)

blog.pamelafox.org/2023/09/moc

#openai #pytest

Last updated 1 year ago

PyCon CZ :python: 🇨🇿 · @pyconcz
41 followers · 35 posts · Server floss.social

👨‍💻 How to maintain ten thousand tests and four thousand fixtures? 👉 Find out in the talk "Pytest: The Case for Using Classes" by Mikuláš Poul. cz.pycon.org/2023/program/talk

#pytest #testautomation

Last updated 1 year ago

Michał Górny · @mgorny
204 followers · 1113 posts · Server pol.social

Dzisiaj testy awscli (1.x) zaczęły nagle się sypał. Oczywiście, `PYTEST_DISABLE_PLUGIN_AUTOLOAD=1` pomogło.

Przy okazji postanowiłem sprawdzić, czy `--forked` jest nadal konieczne. Pamiętam, że kiedyś to dodałem, bo w przeciwnym wypadku testy sypały się przy równoległym uruchamianiu. Dodanie `--forked` spowolniło testy, ale nadal były szybsze niż wykonywane szeregowo.

Okazało się niepotrzebne — albo poprawiono błąd w kodzie, albo problem był powodowany przez inną wtyczkę pytesta. Tak czy siak, `--forked` usunięte i teraz testy przechodzą trzy razy szybciej!

#gentoo #pytest #python

Last updated 1 year ago

Rick Donato · @rickdonato
37 followers · 102 posts · Server hachyderm.io

Fed up with writing tests within Pytest for network testing? Check out how to dynamically generate tests using Pytest Parametrization in our previous post: packetcoders.io/dynamically-ge

#pytest #NetworkAutomation

Last updated 1 year ago

Holly Becker · @hwesta
112 followers · 63 posts · Server wandering.shop

Question involving

Currently, we run end-to-end API tests against a sqlite DB, which takes about 2 seconds. I want to switch to postgres (what we use in prod) but that makes the tests take a lot longer, about 12 seconds.

Is there a way to improve this?

What might be causing the slowness? Where can I look? Is it networking to the docker container? Postgres enforcing constraints? Running flush after every DB fixture? Something else?

#python #sqlalchemy #factoryboy #postgresql #pytest

Last updated 1 year ago

Kevin Bowen :xfce: · @kevinbowen
122 followers · 817 posts · Server fosstodon.org

Today, I rip all of my TestCase & SimpleTestCase tests apart & re-write them for pure as an edumacational experience.

I also get to figure out what the heck is going on with the latest -boy update & why faker is cranky.

This week is all about breaking stuff & piecing it back together. Good times.

#pytest #factory #django

Last updated 1 year ago

Kevin Bowen :xfce: · @kevinbowen
119 followers · 769 posts · Server fosstodon.org

I neglected to mention what the `--durations` flag actually does in

`--durations 10` will show the 10 slowest test durations. This can be modified with the `--durations-min` flag.

I do realize that I am pretty much rathole-ing on minutae for my little projects; but, I find that it is helping me look closer at 'simple' tests and begin to get more selective on my testing efforts. YMMV.

docs.pytest.org/en/latest/how-

#pytest #django

Last updated 1 year ago

~ashwinvis · @ashwinvis
489 followers · 293 posts · Server mastodon.acc.sunet.se

Various ways to skip tests with on ImportError or otherwise.

scivision.dev/pytest-skip-impo

#pytest

Last updated 1 year ago

Jochen Wersdörfer · @jochen
175 followers · 328 posts · Server fedi.wersdoerfer.de

Better backup of media files in django-cast + TIL how to test management commands using - published my for last week: wersdoerfer.de/blogs/ephes_blo

#django #pytest #weeknotes

Last updated 1 year ago

Jürgen Gmach · @jugmac00
379 followers · 1266 posts · Server fosstodon.org

@brianokken We use mattermost.com/ at work.

Have you ever thought to ask the folks for an extra channel on their discord? Would be a win-win situation. Building a new community from scratch is hard.

#pytest

Last updated 1 year ago

Hugh :vm: :python: :cc_cc: · @mobilehugh
11 followers · 26 posts · Server mas.to
Holly Becker · @hwesta
104 followers · 37 posts · Server wandering.shop

Specifically I wanted to add __init__.py files to all my test directories so wouldn't have test collection errors from files with the same name in different directories. I ran

find tests -type dir ! -name '__pycache__' | xargs -I % sh -c 'touch %/__init__.py'

explainshell.com/explain?cmd=f

#pytest

Last updated 1 year ago

Pamela Fox · @pamelafox
2654 followers · 908 posts · Server fosstodon.org

New blog post: Accessibility snapshot testing for Python Web Apps
blog.pamelafox.org/2023/08/acc

#python #pytest #playwright

Last updated 1 year ago

Michał Górny · @mgorny
160 followers · 646 posts · Server pol.social

Zaktualizowałem Guide, i teraz zalecamy `rm -rf` na katalogach, które kolidują z zainstalowanymi paczkami i powodują, że testy nie są w stanie odnaleźć skompilowanych rozszerzeń.

Przedtem zalecaliśmy zmianę katalogu roboczego, ale to było bardziej skomplikowane i czasem powodowało inne problemy ( pomijający pliki konfiguracyjne, testy polegające na względnych ścieżkach).

Dodałem też ostrzeżenie, że brakujące rozszerzenia nie zawsze powodują wystąpienie widocznego błędu.

projects.gentoo.org/python/gui

#pytest #python #gentoo

Last updated 1 year ago

⚡️ · @medecau
18 followers · 264 posts · Server hachyderm.io

devastated about `tox` devs decision to keep using the legacy configuration file for the new version 4

that was the right moment to drop that and support the file everyone else is using

#python #tox #pytest

Last updated 1 year ago

Brian Okken :python: · @brianokken
1875 followers · 974 posts · Server fosstodon.org

Test & Code 205: pytest autouse fixtures - with @falcon

testandcode.com/episodes/pytes

We discuss what pytest fixtures are, what autouse fixtures are, and good times to use them

#python #pytest

Last updated 1 year ago

Sebastian Stein 🇺🇦 · @steinchen
272 followers · 273 posts · Server det.social

It I want to do test driven development in , what framework should I use? Is the most popular one?

#tdd #python #pytest

Last updated 1 year ago

Timothée Mazzucotelli :python: · @pawamoy
151 followers · 260 posts · Server fosstodon.org

devs, can you help? I have a context manager that redirects all stdout/stderr to a pipe (created with os.pipe()). With enough output, it reaches the buffer size and hangs on writing. I only read the whole thing when exiting the context manager.

Any hints on how to handle that? Should I run a reader in a thread? Should I use a named pipe instead (maybe they're not limited by a buffer)? Or maybe a plain temporary file? It seems that's what 's capfd fixture does.

#python #pytest

Last updated 1 year ago

Michał Górny · @mgorny
150 followers · 587 posts · Server pol.social

Dzisiejsza przygoda z pytestem.

zgłasza, że wszystkie testy "async def" nie są uruchamiane, bo nie mam właściwej wtyczki. Tyle że wszystko dzieje się wewnątrz mojego testowego kontenera, który ma przynajmniej kilka wtyczek tego typu, i testy innych paczek nie mają tego problemu!

Okazało się, że muszę podać `--asyncio-mode=auto`.

Nie wpadłbym na to, gdyby nie to, że najpierw podejrzewałem konflikt między wtyczkami i próbowałem PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 z `-p aiohttp`. Wówczas brakująca zależna wtyczka spowodowała powstanie błędu:

INTERNALERROR> ValueError: no option named 'asyncio_mode'

I zadzwoniło we właściwym kościele ;-).

gitweb.gentoo.org/repo/gentoo.

#python #gentoo #pytest

Last updated 1 year ago

Lars Kellogg-Stedman · @larsks
142 followers · 184 posts · Server hachyderm.io

It's been a while! Here's a new blog post about working with and :

blog.oddbit.com/post/2023-07-1

#pytest #containers

Last updated 1 year ago