PyTest - Test Organization
You want to share a database connection setup across multiple test files using
conftest.py. Which approach best follows pytest best practices?conftest.py. Which approach best follows pytest best practices?yield allows setup before tests and cleanup after, ideal for resources like DB connections.conftest.py holding the connection without a fixture lacks cleanup and is not recommended. Use a class with static methods in conftest.py to manage the connection is more complex and less idiomatic.conftest.py that creates and yields the connection, then closes it after tests -> Option A15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions