From b1a5f43e348fdeb8ff080b4137f385815c3835dc Mon Sep 17 00:00:00 2001 From: Evan Hubinger Date: Mon, 9 Oct 2023 23:20:30 -0700 Subject: [PATCH] Improve reqs, tests --- coconut/constants.py | 12 ++++++++---- coconut/tests/main_test.py | 8 ++++++++ coconut/tests/src/cocotest/agnostic/main.coco | 3 +++ .../tests/src/cocotest/target_311/py311_test.coco | 10 ++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 coconut/tests/src/cocotest/target_311/py311_test.coco diff --git a/coconut/constants.py b/coconut/constants.py index 1965516a2..672703edc 100644 --- a/coconut/constants.py +++ b/coconut/constants.py @@ -904,7 +904,8 @@ def get_path_env_var(env_var, default): ("ipython", "py<3"), ("ipython", "py3;py<37"), ("ipython", "py==37"), - ("ipython", "py38"), + ("ipython", "py==38"), + ("ipython", "py>=39"), ("ipykernel", "py<3"), ("ipykernel", "py3;py<38"), ("ipykernel", "py38"), @@ -920,9 +921,10 @@ def get_path_env_var(env_var, default): ("jupyter-console", "py<35"), ("jupyter-console", "py>=35;py<37"), ("jupyter-console", "py37"), - ("jupyterlab", "py35"), - ("jupytext", "py3"), "papermill", + # these are fully optional, so no need to pull them in here + # ("jupyterlab", "py35"), + # ("jupytext", "py3"), ), "mypy": ( "mypy[python2]", @@ -993,7 +995,6 @@ def get_path_env_var(env_var, default): ("jupyter-console", "py37"): (6, 6), ("typing", "py<35"): (3, 10), ("typing_extensions", "py>=37"): (4, 7), - ("ipython", "py38"): (8, 15), ("ipykernel", "py38"): (6,), ("jedi", "py39"): (0, 19), ("pygments", "py>=39"): (2, 15), @@ -1001,9 +1002,12 @@ def get_path_env_var(env_var, default): ("pytest", "py36"): (7,), ("async_generator", "py35"): (1, 10), ("exceptiongroup", "py37"): (1,), + ("ipython", "py>=39"): (8, 15), # pinned reqs: (must be added to pinned_reqs below) + # don't upgrade these; they breaks on Python 3.8 + ("ipython", "py==38"): (8, 12), # don't upgrade these; they breaks on Python 3.7 ("ipython", "py==37"): (7, 34), # don't upgrade these; they breaks on Python 3.6 diff --git a/coconut/tests/main_test.py b/coconut/tests/main_test.py index 22a5f1733..bd094f15f 100644 --- a/coconut/tests/main_test.py +++ b/coconut/tests/main_test.py @@ -562,6 +562,11 @@ def comp_38(args=[], always_sys=False, **kwargs): comp(path="cocotest", folder="target_38", args=["--target", "38" if not always_sys else "sys"] + args, **kwargs) +def comp_311(args=[], always_sys=False, **kwargs): + """Compiles target_311.""" + comp(path="cocotest", folder="target_311", args=["--target", "311" if not always_sys else "sys"] + args, **kwargs) + + def comp_sys(args=[], **kwargs): """Compiles target_sys.""" comp(path="cocotest", folder="target_sys", args=["--target", "sys"] + args, **kwargs) @@ -605,6 +610,8 @@ def run(args=[], agnostic_target=None, use_run_arg=False, convert_to_import=Fals comp_36(args, **spec_kwargs) if sys.version_info >= (3, 8): comp_38(args, **spec_kwargs) + if sys.version_info >= (3, 11): + comp_311(args, **spec_kwargs) comp_agnostic(agnostic_args, **kwargs) comp_sys(args, **kwargs) @@ -646,6 +653,7 @@ def comp_all(args=[], agnostic_target=None, **kwargs): comp_35(args, **kwargs) comp_36(args, **kwargs) comp_38(args, **kwargs) + comp_311(args, **kwargs) comp_sys(args, **kwargs) comp_non_strict(args, **kwargs) diff --git a/coconut/tests/src/cocotest/agnostic/main.coco b/coconut/tests/src/cocotest/agnostic/main.coco index 2e5402122..b6bdbfa59 100644 --- a/coconut/tests/src/cocotest/agnostic/main.coco +++ b/coconut/tests/src/cocotest/agnostic/main.coco @@ -104,6 +104,9 @@ def run_main(outer_MatchError, test_easter_eggs=False) -> bool: if sys.version_info >= (3, 8): from .py38_test import py38_test assert py38_test() is True + if sys.version_info >= (3, 11): + from .py311_test import py311_test + assert py311_test() is True print_dot() # ....... from .target_sys_test import TEST_ASYNCIO, target_sys_test diff --git a/coconut/tests/src/cocotest/target_311/py311_test.coco b/coconut/tests/src/cocotest/target_311/py311_test.coco new file mode 100644 index 000000000..a2c655815 --- /dev/null +++ b/coconut/tests/src/cocotest/target_311/py311_test.coco @@ -0,0 +1,10 @@ +def py311_test() -> bool: + """Performs Python-3.11-specific tests.""" + multi_err = ExceptionGroup("herp", [ValueError("a"), ValueError("b")]) + got_err = None + try: + raise multi_err + except* ValueError as err: + got_err = err + assert repr(got_err) == repr(multi_err), (got_err, multi_err) + return True