##// END OF EJS Templates
add tests, fix exceptiongroup dependency, add doc requirement in another place
jakkdl -
Show More
@@ -0,0 +1,109 b''
1 import unittest
2 import re
3 from IPython.utils.capture import capture_output
4 import sys
5 import pytest
6 from tempfile import TemporaryDirectory
7 from IPython.testing import tools as tt
8
9 def _exceptiongroup_common(
10 outer_chain: str,
11 inner_chain: str,
12 native: bool,
13 ) -> None:
14 pre_raise = "exceptiongroup." if not native else ""
15 pre_catch = pre_raise if sys.version_info < (3, 11) else ""
16 filestr = f"""
17 {"import exceptiongroup" if not native else ""}
18 import pytest
19
20 def f(): raise ValueError("From f()")
21 def g(): raise BaseException("From g()")
22
23 def inner(inner_chain):
24 excs = []
25 for callback in [f, g]:
26 try:
27 callback()
28 except BaseException as err:
29 excs.append(err)
30 if excs:
31 if inner_chain == "none":
32 raise {pre_raise}BaseExceptionGroup("Oops", excs)
33 try:
34 raise SyntaxError()
35 except SyntaxError as e:
36 if inner_chain == "from":
37 raise {pre_raise}BaseExceptionGroup("Oops", excs) from e
38 else:
39 raise {pre_raise}BaseExceptionGroup("Oops", excs)
40
41 def outer(outer_chain, inner_chain):
42 try:
43 inner(inner_chain)
44 except {pre_catch}BaseExceptionGroup as e:
45 if outer_chain == "none":
46 raise
47 if outer_chain == "from":
48 raise IndexError() from e
49 else:
50 raise IndexError
51
52
53 outer("{outer_chain}", "{inner_chain}")
54 """
55 with capture_output() as cap:
56 ip.run_cell(filestr)
57
58 match_lines = []
59 if inner_chain == "another":
60 match_lines += [
61 "During handling of the above exception, another exception occurred:",
62 ]
63 elif inner_chain == 'from':
64 match_lines += [
65 "The above exception was the direct cause of the following exception:",
66 ]
67
68 match_lines += [
69 " + Exception Group Traceback (most recent call last):",
70 f" | {pre_catch}BaseExceptionGroup: Oops (2 sub-exceptions)",
71 " | ValueError: From f()",
72 " | BaseException: From g()",
73 ]
74
75 if outer_chain == "another":
76 match_lines += [
77 "During handling of the above exception, another exception occurred:",
78 "IndexError",
79 ]
80 elif outer_chain == "from":
81 match_lines += [
82 "The above exception was the direct cause of the following exception:",
83 "IndexError",
84 ]
85
86 error_lines = cap.stderr.split("\n")
87
88 err_index = match_index = 0
89 for expected in match_lines:
90 for i,actual in enumerate(error_lines):
91 if actual == expected:
92 error_lines = error_lines[i+1:]
93 break
94 else:
95 assert False, f'{expected} not found in cap.stderr'
96
97 @pytest.mark.skipif(
98 sys.version_info < (3, 11), reason="Native ExceptionGroup not implemented"
99 )
100 @pytest.mark.parametrize("outer_chain", ["none", "from", "another"])
101 @pytest.mark.parametrize("inner_chain", ["none", "from", "another"])
102 def test_native_exceptiongroup(outer_chain, inner_chain) -> None:
103 _exceptiongroup_common(outer_chain, inner_chain, native=True)
104
105 @pytest.mark.parametrize("outer_chain", ["none", "from", "another"])
106 @pytest.mark.parametrize("inner_chain", ["none", "from", "another"])
107 def test_native_exceptiongroup(outer_chain, inner_chain) -> None:
108 pytest.importorskip("exceptiongroup")
109 _exceptiongroup_common(outer_chain, inner_chain, native=False)
@@ -1,19 +1,20 b''
1 name: ipython_docs
1 name: ipython_docs
2 channels:
2 channels:
3 - conda-forge
3 - conda-forge
4 - defaults
4 - defaults
5 dependencies:
5 dependencies:
6 - python=3.10
6 - python=3.10
7 - setuptools
7 - setuptools
8 - sphinx>=4.2
8 - sphinx>=4.2
9 - sphinx_rtd_theme
9 - sphinx_rtd_theme
10 - numpy
10 - numpy
11 - exceptiongroup
11 - testpath
12 - testpath
12 - matplotlib
13 - matplotlib
13 - pip
14 - pip
14 - pip:
15 - pip:
15 - docrepr
16 - docrepr
16 - prompt_toolkit
17 - prompt_toolkit
17 - ipykernel
18 - ipykernel
18 - stack_data
19 - stack_data
19 - -e ..
20 - -e ..
@@ -1,118 +1,118 b''
1 [metadata]
1 [metadata]
2 name = ipython
2 name = ipython
3 version = attr: IPython.core.release.__version__
3 version = attr: IPython.core.release.__version__
4 url = https://ipython.org
4 url = https://ipython.org
5 description = IPython: Productive Interactive Computing
5 description = IPython: Productive Interactive Computing
6 long_description_content_type = text/x-rst
6 long_description_content_type = text/x-rst
7 long_description = file: long_description.rst
7 long_description = file: long_description.rst
8 license_file = LICENSE
8 license_file = LICENSE
9 project_urls =
9 project_urls =
10 Documentation = https://ipython.readthedocs.io/
10 Documentation = https://ipython.readthedocs.io/
11 Funding = https://numfocus.org/
11 Funding = https://numfocus.org/
12 Source = https://github.com/ipython/ipython
12 Source = https://github.com/ipython/ipython
13 Tracker = https://github.com/ipython/ipython/issues
13 Tracker = https://github.com/ipython/ipython/issues
14 keywords = Interactive, Interpreter, Shell, Embedding
14 keywords = Interactive, Interpreter, Shell, Embedding
15 platforms = Linux, Mac OSX, Windows
15 platforms = Linux, Mac OSX, Windows
16 classifiers =
16 classifiers =
17 Framework :: IPython
17 Framework :: IPython
18 Framework :: Jupyter
18 Framework :: Jupyter
19 Intended Audience :: Developers
19 Intended Audience :: Developers
20 Intended Audience :: Science/Research
20 Intended Audience :: Science/Research
21 License :: OSI Approved :: BSD License
21 License :: OSI Approved :: BSD License
22 Programming Language :: Python
22 Programming Language :: Python
23 Programming Language :: Python :: 3
23 Programming Language :: Python :: 3
24 Programming Language :: Python :: 3 :: Only
24 Programming Language :: Python :: 3 :: Only
25 Topic :: System :: Shells
25 Topic :: System :: Shells
26
26
27 [options]
27 [options]
28 packages = find:
28 packages = find:
29 python_requires = >=3.9
29 python_requires = >=3.9
30 zip_safe = False
30 zip_safe = False
31 install_requires =
31 install_requires =
32 appnope; sys_platform == "darwin"
32 appnope; sys_platform == "darwin"
33 backcall
33 backcall
34 colorama; sys_platform == "win32"
34 colorama; sys_platform == "win32"
35 decorator
35 decorator
36 exceptiongroup; python_version<'3.10'
36 exceptiongroup; python_version<'3.11'
37 jedi>=0.16
37 jedi>=0.16
38 matplotlib-inline
38 matplotlib-inline
39 pexpect>4.3; sys_platform != "win32"
39 pexpect>4.3; sys_platform != "win32"
40 pickleshare
40 pickleshare
41 prompt_toolkit>=3.0.30,<3.1.0,!=3.0.37
41 prompt_toolkit>=3.0.30,<3.1.0,!=3.0.37
42 pygments>=2.4.0
42 pygments>=2.4.0
43 stack_data
43 stack_data
44 traitlets>=5
44 traitlets>=5
45 typing_extensions ; python_version<'3.10'
45 typing_extensions ; python_version<'3.10'
46
46
47 [options.extras_require]
47 [options.extras_require]
48 black =
48 black =
49 black
49 black
50 doc =
50 doc =
51 ipykernel
51 ipykernel
52 setuptools>=18.5
52 setuptools>=18.5
53 sphinx>=1.3
53 sphinx>=1.3
54 sphinx-rtd-theme
54 sphinx-rtd-theme
55 docrepr
55 docrepr
56 matplotlib
56 matplotlib
57 stack_data
57 stack_data
58 pytest<7
58 pytest<7
59 typing_extensions
59 typing_extensions
60 exceptiongroup
60 exceptiongroup
61 %(test)s
61 %(test)s
62 kernel =
62 kernel =
63 ipykernel
63 ipykernel
64 nbconvert =
64 nbconvert =
65 nbconvert
65 nbconvert
66 nbformat =
66 nbformat =
67 nbformat
67 nbformat
68 notebook =
68 notebook =
69 ipywidgets
69 ipywidgets
70 notebook
70 notebook
71 parallel =
71 parallel =
72 ipyparallel
72 ipyparallel
73 qtconsole =
73 qtconsole =
74 qtconsole
74 qtconsole
75 terminal =
75 terminal =
76 test =
76 test =
77 pytest<7.1
77 pytest<7.1
78 pytest-asyncio
78 pytest-asyncio
79 testpath
79 testpath
80 test_extra =
80 test_extra =
81 %(test)s
81 %(test)s
82 curio
82 curio
83 matplotlib!=3.2.0
83 matplotlib!=3.2.0
84 nbformat
84 nbformat
85 numpy>=1.21
85 numpy>=1.21
86 pandas
86 pandas
87 trio
87 trio
88 all =
88 all =
89 %(black)s
89 %(black)s
90 %(doc)s
90 %(doc)s
91 %(kernel)s
91 %(kernel)s
92 %(nbconvert)s
92 %(nbconvert)s
93 %(nbformat)s
93 %(nbformat)s
94 %(notebook)s
94 %(notebook)s
95 %(parallel)s
95 %(parallel)s
96 %(qtconsole)s
96 %(qtconsole)s
97 %(terminal)s
97 %(terminal)s
98 %(test_extra)s
98 %(test_extra)s
99 %(test)s
99 %(test)s
100
100
101 [options.packages.find]
101 [options.packages.find]
102 exclude =
102 exclude =
103 setupext
103 setupext
104
104
105 [options.package_data]
105 [options.package_data]
106 IPython = py.typed
106 IPython = py.typed
107 IPython.core = profile/README*
107 IPython.core = profile/README*
108 IPython.core.tests = *.png, *.jpg, daft_extension/*.py
108 IPython.core.tests = *.png, *.jpg, daft_extension/*.py
109 IPython.lib.tests = *.wav
109 IPython.lib.tests = *.wav
110 IPython.testing.plugin = *.txt
110 IPython.testing.plugin = *.txt
111
111
112 [velin]
112 [velin]
113 ignore_patterns =
113 ignore_patterns =
114 IPython/core/tests
114 IPython/core/tests
115 IPython/testing
115 IPython/testing
116
116
117 [tool.black]
117 [tool.black]
118 exclude = 'timing\.py'
118 exclude = 'timing\.py'
General Comments 0
You need to be logged in to leave comments. Login now