I've been developing some pytest idioms at work (startup), in an attempt to
make it not just part of the process, or a disapproving look at code
review, or a "*shrug* well, that's startup culture #yolo
#youonlylaunchonce"... but as a feature scaffolding tool. I figure, if it
can help develop features *quicker*, peoples will *want* to use it.

Since you asked, of course I'll pause for a quick personal aside! Ya see,
when I was growings up, my pa used to say "Zach, do whatever the hell you
want, but only put on the credit card what you have in the bank." Working
at a start-up, the pressure to fart out features sometimes makes skipping
testing seem like it aligns with business goals. If my dad were here now,
or understood anything about what I do for work, he'd slap their hands —
"yeah, you can purchase the feature with your credit card, son, but you
don't own it." Unlike regular debt, when technical debt piles up, and
there's no time left in the day to work another job to pay it all off,
there's no bankruptcy — there are only two options: forced labor, or DEATH!

Anyway, I found with a more compact form of expression for test fixtures, I
experimented more, and upon returning to those tests months later, I found
I could skim through the code and grok it well.

pytest-lambda <https://github.com/theY4Kman/pytest-lambda> offers
`lambda_fixture`, which is essentially just `pytest.fixture` whose name is
derived from the attribute it's assigned to. As well, for convenience, it
also offers:

   - `static_fixture` — to return static value
   - `error_fixture` — to raise an exception
   - `not_implemented_fixture` — to raise a NotImplementedError, useful for
   abstract test mixins
   - `disabled_fixture` — to raise a HeyDontUseThisThingError (not really,
   but you get the idea), useful for failing early on known erroneous
   environments — 0xDEADBEEFing like the wholesome dev you are


Also, I think this is my first message to the list, so, uh, hi, y'all! I'm
Zach, I work for a cybersecurity startup. I fell in love with Python at an
early age, embedding <https://github.com/theY4Kman/viper> it into
Counter-Strike: Source 'cause I didn't want to use the C-like Pawn lang to
write plugins. Years later, I discovered pytest and fell deeply in love. I
gave a shot porting <https://github.com/theY4Kman/pysmx> the Pawn VM to
Python, so people could test their plugins with pytest. One day I got my
first tattoo, on the same day I got a Python tattoo, and can you believe
it, on the same day I got my only tattoo. I'm occasionally long-winded, I
think stuffy docs are unread docs, and it's a pleasure to meet y'all :)

Cheers,
Zach "theY4Kman" Kanzler
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to