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 makepytest
stand out above other test frameworks, and are the reason why many people switch to and stay withpytest
(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 adb
fixture to instantiate this class and run itsinit
method to get the movies table created and populated. At the end of the fixture you usedrop_table
to undo any changes.Apart from this setup and teardown there are 3 methods you need to test:
query
,add
anddelete
. Speciallyquery
has 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
pytest
learning path ... Good luck and keep calm and code in Python /pytest
!
66 out of 66 users completed this Bite.
Will you be the 67th person to crack this Bite?
Resolution time: ~88 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 6.5 on a 1-10 difficulty scale.
» Up for a challenge? 💪