cs50 / problems

Checks for check50
145 stars 237 forks source link

CS50P: Working 9 to 5 test fails if student uses words "from" or "import" in expected contexts #267

Closed Makaze closed 3 months ago

Makaze commented 3 months ago

The second test fails if the student uses the word "from" anywhere in their code, such as a pattern.

Minimal failing example:

import re
import sys

"""from now on, we will work 9 to 5!"""
"""imports must be normal"""

Either of the last two lines will fail the test. This bug was revealed when a student used named capture groups in their regular expression and named one "from".

This happens due to the import checking pattern, which can be fixed by adding some extra sanity checks for the statement being at the start of the line.