0
0
PyTesttesting~10 mins

PyTest vs unittest vs nose comparison - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the unittest module correctly.

PyTest
import [1]
Drag options to blanks, or click blank then click option'
Aunittest
Bpytest
Cnose
Dtest
Attempts:
3 left
💡 Hint
Common Mistakes
Importing pytest or nose instead of unittest.
2fill in blank
medium

Complete the code to write a simple test function using pytest.

PyTest
def test_addition():
    assert 1 + 1 == [1]
Drag options to blanks, or click blank then click option'
A0
B3
C11
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong expected value in assertion.
3fill in blank
hard

Fix the error in the unittest test case method name to make it run automatically.

PyTest
import unittest

class TestMath(unittest.TestCase):
    def [1](self):
        self.assertEqual(2 + 2, 4)
Drag options to blanks, or click blank then click option'
Atest_addition
Baddition_test
Crun_test
Dcheck_add
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names that do not start with 'test_'.
4fill in blank
hard

Fill both blanks to create a nose test function that asserts True is True.

PyTest
def [1]():
    assert [2] is True
Drag options to blanks, or click blank then click option'
Atest_true
BTrue
Cfalse
Dcheck_true
Attempts:
3 left
💡 Hint
Common Mistakes
Function name not starting with 'test_' or wrong assertion value.
5fill in blank
hard

Fill all three blanks to write a pytest test that checks if a list contains a value.

PyTest
def [1]():
    items = [1, 2, 3]
    assert [2] in [3]
Drag options to blanks, or click blank then click option'
Atest_contains
B2
Citems
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong function name or wrong values in assertion.