From 6473ac8b3ed75faa5523a6abb7fff0813db54add Mon Sep 17 00:00:00 2001 From: Evan Hubinger Date: Sun, 6 Aug 2023 12:32:03 -0700 Subject: [PATCH] Add missing import test --- coconut/tests/src/extras.coco | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/coconut/tests/src/extras.coco b/coconut/tests/src/extras.coco index 79de0f5f7..b3ba40208 100644 --- a/coconut/tests/src/extras.coco +++ b/coconut/tests/src/extras.coco @@ -348,6 +348,16 @@ else: assert_raises(-> parse("def x -> pass, 1"), CoconutStyleError, err_has="statement lambda") assert_raises(-> parse("abc = f'abc'"), CoconutStyleError, err_has="\n ^") assert_raises(-> parse('f"{f"{f"infinite"}"}"'), CoconutStyleError, err_has=" ^~~~~~~~~~~|") + try: + parse(""" +import abc +1 +2 +3 + """.strip()) + except CoconutStyleError as err: + assert str(err) == """found unused import 'abc' (add '# NOQA' to suppress) (remove --strict to downgrade to a warning) (line 1) + import abc""" setup(line_numbers=False, strict=True, target="sys") assert_raises(-> parse("await f x"), CoconutParseError, err_has='invalid use of the keyword "await"')