0
0
PyTesttesting~10 mins

Test naming conventions in PyTest - Interactive Code Practice

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

Complete the code to name the test function correctly so pytest recognizes it.

PyTest
def [1]():
    assert 1 + 1 == 2
Drag options to blanks, or click blank then click option'
Acheck_add
Baddition_test
Ctest_addition
DAddTest
Attempts:
3 left
💡 Hint
Common Mistakes
Naming test functions without 'test_' prefix
Using camel case instead of snake case
2fill in blank
medium

Complete the code to name the test class correctly so pytest recognizes it.

PyTest
class [1]:
    def test_example(self):
        assert True
Drag options to blanks, or click blank then click option'
ATestExample
BTestsExample
Cexample_test
DExampleTests
Attempts:
3 left
💡 Hint
Common Mistakes
Not starting class name with 'Test'
Using snake_case for class names
3fill in blank
hard

Fix the error in the test function name so pytest will run it.

PyTest
def [1]():
    assert 'hello'.upper() == 'HELLO'
Drag options to blanks, or click blank then click option'
Acheck_uppercase
Btest_uppercase
CuppercaseTest
Dverify_upper
Attempts:
3 left
💡 Hint
Common Mistakes
Missing 'test_' prefix
Using camelCase instead of snake_case
4fill in blank
hard

Fill both blanks to correctly name the test function and parameter for pytest.

PyTest
def [1]([2]):
    assert [2] * 2 == 4
Drag options to blanks, or click blank then click option'
Atest_double
Binput_value
Cvalue
Ddouble_test
Attempts:
3 left
💡 Hint
Common Mistakes
Function name missing 'test_' prefix
Using invalid or unclear parameter names
5fill in blank
hard

Fill all three blanks to correctly name the test class, test method, and parameter for pytest.

PyTest
class [1]:
    def [2](self, [3]):
        assert [3] + 1 == 3
Drag options to blanks, or click blank then click option'
ATestMath
Btest_increment
Cnumber
DMathTest
Attempts:
3 left
💡 Hint
Common Mistakes
Class name not starting with 'Test'
Method name missing 'test_' prefix
Unclear parameter names