Use fixture instance in non-test classes #11619
Unanswered
peppe-russo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone, I'm writing a pytest plugin that uses pytest-vnc as a dependency. The way I use it is to wrap it around my own custom fixture to override the
sleep
method, like so:I then have an
Area
class in another file that I use quite often around my plugin, which needs to use thatVNC
instance (or more precisely, theqt_vnc
fixture), example:The current way I'm doing this is to have an optional
vnc
field to theArea
class and just pass the fixture to it when I instanciate the class, which doesn't look very elegant and it's not always possible as I use this class from places where I can't easily access the fixture.Is there a "proper" way to make the
qt_vnc
fixture like a global singleton or something like that so I can access it from my custom classes? (TheArea
class is not the only class that needs to use it).Thanks in advance,
Peppe
Beta Was this translation helpful? Give feedback.
All reactions