From edfdf3da144d285eba8d3e9208b8dfbbc0f19770 Mon Sep 17 00:00:00 2001 From: Lukas Brinias Date: Sat, 8 Nov 2025 00:17:04 +0100 Subject: [PATCH] Same as goldbachTest.py --- tests/numbers/eratosthenesTest.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/numbers/eratosthenesTest.py b/tests/numbers/eratosthenesTest.py index de5bd6d..b2af57a 100644 --- a/tests/numbers/eratosthenesTest.py +++ b/tests/numbers/eratosthenesTest.py @@ -7,9 +7,16 @@ @test() def noBreakAndImport(): """Checking for disallowed code.""" - not_allowed = [ast.Break, ast.Import, ast.ImportFrom] - disallow(not_allowed) + imports = static.getAstNodes(ast.Import) + for node in imports: + for alias in node.names: + if alias.name != "math": + raise AssertionError("you cannot use import statements (only 'import math' is allowed)") + if static.getAstNodes(ast.ImportFrom): + raise AssertionError("you cannot use import statements (only 'import math' is allowed)") + + assert ast.Break not in static.AbstractSyntaxTree(), "you cannot use break statements" @test() def test1():