Login and get coding
Note this is a Test Bite and uses Python 3.7 and MutPy 0.6.1
Time for fixtures, one of
pytest's killer features or as Brian Okken said: pytest fixtures are one of the unique core features that make
pyteststand out above other test frameworks, and are the reason why many people switch to and stay with
pytest(Python Testing with pytest).
Why fixtures? The purpose of test fixtures is to provide a fixed baseline upon which tests can reliably and repeatedly execute. pytest fixtures offer dramatic improvements over the classic xUnit style of setup/teardown functions (docs).
In this Bite we wrote a little movie DB using
sqlite3. The idea is that you write a
dbfixture to instantiate this class and run its
initmethod to get the movies table created and populated. At the end of the fixture you use
drop_tableto undo any changes.
Apart from this setup and teardown there are 3 methods you need to test:
queryhas various args, so make sure you test them all.
Apart from the docs we also wrote an article on fixtures you might want to check out: All You Need to Know to Start Using Fixtures in Your pytest Code.
Let us know on Twitter when you finish our
pytestlearning path ... Good luck and keep calm and code in Python /
60 out of 60 users completed this Bite.
Will you be Pythonista #61 to crack this Bite?
Resolution time: ~90 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 6.5 on a 1-10 difficulty scale.
» Up for a challenge? 💪