Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 committed Aug 5, 2024
1 parent e0516fd commit 7217698
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion starlark.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ PyDoc_STRVAR(
"* Python :py:obj:`python:set` to Starlark `set "
"<https://pkg.go.dev/go.starlark.net/starlark#Set>`_\n"
"* Python :py:obj:`python:tuple` to Starlark `tuple "
"<https://pkg.go.dev/go.starlark.net/starlark#Tuple>`_\n\n"
"<https://pkg.go.dev/go.starlark.net/starlark#Tuple>`_\n"
"* Python functions can be registered as a Starlark function directly. "
"Any exceptions raised will be rethrown as :py:class:`EvalError`.\n"
"\n"
"For the aggregate types (``dict``, ``list``, ``set``, and ``tuple``,) all keys "
"and/or values must also be one of the supported types.\n\n"
"Attempting to set a value of any other Python type will raise a "
Expand Down
14 changes: 10 additions & 4 deletions tests/test_set_globals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest

from starlark_go import EvalError, Starlark, StarlarkError
Expand Down Expand Up @@ -188,10 +190,12 @@ def func_impl(x):
with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: got zero"):
s.eval("func(0)")

with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: test_func.<locals>.func_impl\(\) missing 1 required positional argument: 'x'"):
name = "func_impl" if sys.version_info < (3, 10) else "test_func.<locals>.func_impl"

with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: " + name + r"\(\) missing 1 required positional argument: 'x'"):
s.eval("func()")

with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: test_func.<locals>.func_impl\(\) got an unexpected keyword argument 'unknown'"):
with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: " + name + r"\(\) got an unexpected keyword argument 'unknown'"):
s.eval("func(unknown=0)")


Expand Down Expand Up @@ -240,10 +244,12 @@ def func_impl(self, x):
with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: got zero"):
s.exec("func(0)")

with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: test_method.<locals>.Test.func_impl\(\) missing 1 required positional argument: 'x'"):
name = "func_impl" if sys.version_info < (3, 10) else "test_method.<locals>.Test.func_impl"

with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: " + name + r"\(\) missing 1 required positional argument: 'x'"):
s.eval("func()")

with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: test_method.<locals>.Test.func_impl\(\) got an unexpected keyword argument 'unknown'"):
with pytest.raises(EvalError, match=r"<builtin> in func_impl:0:0: " + name + r"\(\) got an unexpected keyword argument 'unknown'"):
s.eval("func(unknown=0)")


Expand Down

0 comments on commit 7217698

Please sign in to comment.