From 2eac70d5eea60db0b9949ec2d7b7d3731330b88a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sun, 17 Nov 2024 14:00:31 +0700 Subject: [PATCH] add a test --- .../exceptions/test_syntax_exception.py | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/functional/syntax/exceptions/test_syntax_exception.py b/tests/functional/syntax/exceptions/test_syntax_exception.py index 80f499ac89..8d9b964186 100644 --- a/tests/functional/syntax/exceptions/test_syntax_exception.py +++ b/tests/functional/syntax/exceptions/test_syntax_exception.py @@ -1,5 +1,6 @@ import pytest +from vyper.compiler import compile_code from vyper.exceptions import SyntaxException fail_list = [ @@ -107,5 +108,29 @@ def foo(): @pytest.mark.parametrize("bad_code", fail_list) -def test_syntax_exception(assert_compile_failed, get_contract, bad_code): - assert_compile_failed(lambda: get_contract(bad_code), SyntaxException) +def test_syntax_exception(bad_code): + with pytest.raises(SyntaxException): + compile_code(bad_code) + + +def test_bad_staticcall_keyword(): + bad_code = """ +from ethereum.ercs import IERC20Detailed + +def foo(): + staticcall ERC20(msg.sender).transfer(msg.sender, staticall IERC20Detailed(msg.sender).decimals()) + """.strip() + with pytest.raises(SyntaxException) as e: + compile_code(bad_code) + + expected_error = """ +Possible typo: `staticall` + + line 4:54 + 3 def foo(): + ---> 4 staticcall ERC20(msg.sender).transfer(msg.sender, staticall IERC20Detailed(msg.sender).decimals()) + -------------------------------------------------------------^ + + (hint: did you mean `staticcall`?) + """ # noqa + assert str(e.value) == expected_error.strip()