0
0
Testing Fundamentalstesting~10 mins

Code review as testing in Testing Fundamentals - Interactive Code Practice

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

Complete the code to check if a function has a missing return statement during code review.

Testing Fundamentals
def check_return(func):
    source = func.__code__.co_code
    if [1] not in source:
        return False
    return True
Drag options to blanks, or click blank then click option'
ALOAD_FAST
BRETURN_VALUE
CCALL_FUNCTION
DLOAD_CONST
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing other opcodes like LOAD_CONST or CALL_FUNCTION with return.
2fill in blank
medium

Complete the code to identify if a variable name follows naming conventions during code review.

Testing Fundamentals
def is_valid_var(name):
    import re
    pattern = r'^[a-z_][a-z0-9_]*$'
    return bool(re.match([1], name))
Drag options to blanks, or click blank then click option'
A'^[A-Z][a-zA-Z0-9]*$'
B'^[A-Za-z]+$'
C'^[0-9][a-z_]*$'
D'^[a-z_][a-z0-9_]*$'
Attempts:
3 left
💡 Hint
Common Mistakes
Using patterns that allow uppercase first letters or digits at start.
3fill in blank
hard

Fix the error in the code review function that checks for TODO comments in code.

Testing Fundamentals
def has_todo_comment(code_lines):
    for line in code_lines:
        if '[1]' in line:
            return True
    return False
Drag options to blanks, or click blank then click option'
A"todo"
B"TODO"
C"# TODO"
D"#todo"
Attempts:
3 left
💡 Hint
Common Mistakes
Searching only for 'TODO' without the comment symbol, causing false positives.
4fill in blank
hard

Fill both blanks to create a code review function that finds functions missing docstrings.

Testing Fundamentals
def missing_docstring(func):
    doc = func.__doc__
    if doc is [1] or doc.strip() == [2]:
        return True
    return False
Drag options to blanks, or click blank then click option'
ANone
B""
C"None"
D''
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for string 'None' instead of None type.
5fill in blank
hard

Fill all three blanks to create a code review snippet that collects all function names missing type hints.

Testing Fundamentals
def functions_missing_type_hints(module):
    missing = []
    for name, func in module.__dict__.items():
        if callable(func) and ([1] not in func.__annotations__ or [2] not in func.__annotations__):
            missing.append([3])
    return missing
Drag options to blanks, or click blank then click option'
A"return"
B"param"
Cname
D"return_type"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect keys for annotations or appending the wrong variable.