[TIP] get fixtures for each parameter or global variables?

Ben Finney ben+python at benfinney.id.au
Fri Oct 21 17:17:06 PDT 2016

James <bjlockie at lockie.ca> writes:

> I'm trying to store the parameters in global variables so it doesn't
> need to do pytest.config.getoption every time it wants a parameter.

Please don't. Global state makes your program much more difficult to
understand, because it means you can't limit the range of what may have
caused an unexpected change.

The feature of encapsulating complex structures inside namespaces is a
Python feature. What are you hoping to gain by subverting that?

 \                   德不孤、必有鄰。 (The virtuous are not abandoned, |
  `\                               they shall surely have neighbours.) |
_o__)                            —孔夫子 Confucius (551 BCE – 479 BCE) |
Ben Finney

More information about the testing-in-python mailing list