How to easily manage environment variables with Pytest

Stu Burgoyne
3 min readJul 5, 2024

Found myself on a new project recently which can often be a scary place. New tooling, new processes, new docs (or lack there of), the list goes on. What I often find makes things trickier, is if you’re picking up a project that hasn’t been touched in a while and/or was written by someone who is no longer with the team.

Quick scan of the readme after cloning the project however left me feeling a little more confident (the fact someone had actually bothered to fill it out is usually a good start).

I began working through the steps to get up and running. Interestingly, this was a much larger project with a number of smaller Python lambda’s embedded within (no doubt too small to really warrant their own repo).

The install steps were simple:

  • Navigate to said directory
  • Run poetry install
  • In theory, good to go…

Great I thought, let’s get some packages installed.

This part of the project had minimal dependencies given it was a small lambda so I quickly got to the point of try running it. One the prior steps was to install poetry-exec-plugin which can be done by using poetry self add poetry-exec-plugin, essentially a bolt on that can execute scripts defined in your pyproject.toml

--

--