Skip to content

Update fCC curriculum-help page to clarify how to assert absence of function calls using Python AST helper. #1121

@AdityaSingh-18

Description

@AdityaSingh-18

Describe the bug

The Python AST helper documentation clearly explains how to detect the presence of syntax elements such as function calls using helpers like has_call() and block_has_call(). These helpers return boolean values and are commonly used in FreeCodeCamp Python challenge tests.

However, the documentation does not explicitly show how to assert that a function call should not exist in the camper’s code (for example, when a challenge instructs learners to remove a print() statement).

While this can be achieved by negating the boolean result using standard Python logic e.g. assert not Node(code).has_call("print"), this pattern is currently implicit rather than documented. This can be confusing for new contributors or curriculum authors who are looking for a clear, documented example of how to test for the absence of a statement.

To Reproduce

Add a short example or note to the documentation demonstrating how to assert non-existence, for example:

Assert that a function call does not exist:

assert not Node(code).has_call("print('hello')")
assert not Node(code).block_has_call("print")

Expected behavior

This would improve clarity and reduce friction for contributors writing tests that enforce removal of specific statements.

Screenshots

No response

Desktop OS

No response

Desktop Browser

No response

Desktop Browser Version

No response

Mobile Device

No response

Mobile OS

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions