Parametrize global variables best practice #10182
Replies: 3 comments
-
Without an more detailed example we can't give any suggestion Please show a example piece of code that demonstrates what you want to work so we can suggest a fit solution/workaround |
Beta Was this translation helpful? Give feedback.
-
An example like @RonnyPfannschmidt asked would make things more clear, but from what I can gather, I think you can use a parametrized fixture to solve your problem. |
Beta Was this translation helpful? Give feedback.
-
So here is what I have so far and what I'm trying to achieve. I have a two fixtures with session scope. I generate two sets of user data (a tuple of strings: username, email) but only actually create one of the users. Notice that setup_user depends on
I then want some way of passing both Criteria:
Its really a shame that this didnt work because its so close to what I want |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm using pytest to test my sqlalchemy backend and I found that for most of my tests, i need to see how my code behaves when a speficied user exists and when it doesn't.
I keep having to write this check manually at the beginning of each test but it occured to me that if I could create two users at the beginning of the testing session, only actually create one of them, and then pass both to my tests through the parametrize decorator then i could conveniently check both cases.
But here are the problems:
This was so close to being what I wanted but I kept getting
TypeError: object of type 'LazyFixture' has no len()
. My fixture returns a tuple by the way.I know this is a little obscure but I have to imagine I'm not the first person to want to do something like this. Does anyone have any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions