Show More
@@ -15,13 +15,13 b' jobs:' | |||
|
15 | 15 | strategy: |
|
16 | 16 | matrix: |
|
17 | 17 | os: [ubuntu-latest] |
|
18 | python-version: ["3.7", "3.8", "3.9"] | |
|
18 | python-version: ["3.7", "3.8", "3.9", "3.10"] | |
|
19 | 19 | # Test all on ubuntu, test ends on macos |
|
20 | 20 | include: |
|
21 | 21 | - os: macos-latest |
|
22 | 22 | python-version: "3.7" |
|
23 | 23 | - os: macos-latest |
|
24 |
python-version: "3. |
|
|
24 | python-version: "3.10" | |
|
25 | 25 | |
|
26 | 26 | steps: |
|
27 | 27 | - uses: actions/checkout@v2 |
@@ -305,13 +305,13 b' def find_file(obj) -> str:' | |||
|
305 | 305 | fname = None |
|
306 | 306 | try: |
|
307 | 307 | fname = inspect.getabsfile(obj) |
|
308 | except TypeError: | |
|
308 | except (OSError, TypeError): | |
|
309 | 309 | # For an instance, the file that matters is where its class was |
|
310 | 310 | # declared. |
|
311 | 311 | if hasattr(obj, '__class__'): |
|
312 | 312 | try: |
|
313 | 313 | fname = inspect.getabsfile(obj.__class__) |
|
314 | except TypeError: | |
|
314 | except (OSError, TypeError): | |
|
315 | 315 | # Can happen for builtins |
|
316 | 316 | pass |
|
317 | 317 | except: |
@@ -12,6 +12,7 b' import unittest' | |||
|
12 | 12 | from contextlib import contextmanager |
|
13 | 13 | |
|
14 | 14 | import nose.tools as nt |
|
15 | import pytest | |
|
15 | 16 | |
|
16 | 17 | from traitlets.config.loader import Config |
|
17 | 18 | from IPython import get_ipython |
@@ -29,6 +30,15 b' from IPython.core.completer import (' | |||
|
29 | 30 | ) |
|
30 | 31 | from nose.tools import assert_in, assert_not_in |
|
31 | 32 | |
|
33 | if sys.version_info >= (3, 10): | |
|
34 | import jedi | |
|
35 | from pkg_resources import parse_version | |
|
36 | ||
|
37 | # Requires https://github.com/davidhalter/jedi/pull/1795 | |
|
38 | jedi_issue = parse_version(jedi.__version__) <= parse_version("0.18.0") | |
|
39 | else: | |
|
40 | jedi_issue = False | |
|
41 | ||
|
32 | 42 | # ----------------------------------------------------------------------------- |
|
33 | 43 | # Test functions |
|
34 | 44 | # ----------------------------------------------------------------------------- |
@@ -381,6 +391,8 b' class TestCompleter(unittest.TestCase):' | |||
|
381 | 391 | matches = c.all_completions("TestCl") |
|
382 | 392 | assert matches == ['TestClass'], jedi_status |
|
383 | 393 | matches = c.all_completions("TestClass.") |
|
394 | if jedi_status and jedi_issue: | |
|
395 | continue | |
|
384 | 396 | assert len(matches) > 2, jedi_status |
|
385 | 397 | matches = c.all_completions("TestClass.a") |
|
386 | 398 | assert matches == ['TestClass.a', 'TestClass.a1'], jedi_status |
@@ -435,6 +447,7 b' class TestCompleter(unittest.TestCase):' | |||
|
435 | 447 | "encoding" in c.signature |
|
436 | 448 | ), "Signature of function was not found by completer" |
|
437 | 449 | |
|
450 | @pytest.mark.xfail(jedi_issue, reason="Known failure on jedi<=0.18.0") | |
|
438 | 451 | def test_deduplicate_completions(self): |
|
439 | 452 | """ |
|
440 | 453 | Test that completions are correctly deduplicated (even if ranges are not the same) |
@@ -7,6 +7,7 b'' | |||
|
7 | 7 | #----------------------------------------------------------------------------- |
|
8 | 8 | |
|
9 | 9 | import argparse |
|
10 | import sys | |
|
10 | 11 | from nose.tools import assert_equal |
|
11 | 12 | |
|
12 | 13 | from IPython.core.magic_arguments import (argument, argument_group, kwds, |
@@ -74,7 +75,12 b' def foo(self, args):' | |||
|
74 | 75 | |
|
75 | 76 | |
|
76 | 77 | def test_magic_arguments(): |
|
77 | assert_equal(magic_foo1.__doc__, '::\n\n %foo1 [-f FOO]\n\n A docstring.\n\noptional arguments:\n -f FOO, --foo FOO an argument\n') | |
|
78 | # “optional arguments” was replaced with “options” in argparse help | |
|
79 | # https://docs.python.org/3/whatsnew/3.10.html#argparse | |
|
80 | # https://bugs.python.org/issue9694 | |
|
81 | options = "optional arguments" if sys.version_info < (3, 10) else "options" | |
|
82 | ||
|
83 | assert_equal(magic_foo1.__doc__, f"::\n\n %foo1 [-f FOO]\n\n A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n") | |
|
78 | 84 | assert_equal(getattr(magic_foo1, 'argcmd_name', None), None) |
|
79 | 85 | assert_equal(real_name(magic_foo1), 'foo1') |
|
80 | 86 | assert_equal(magic_foo1(None, ''), argparse.Namespace(foo=None)) |
@@ -86,32 +92,32 b' def test_magic_arguments():' | |||
|
86 | 92 | assert_equal(magic_foo2(None, ''), argparse.Namespace()) |
|
87 | 93 | assert hasattr(magic_foo2, 'has_arguments') |
|
88 | 94 | |
|
89 |
assert_equal(magic_foo3.__doc__, |
|
|
95 | assert_equal(magic_foo3.__doc__, f"::\n\n %foo3 [-f FOO] [-b BAR] [-z BAZ]\n\n A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n\nGroup:\n -b BAR, --bar BAR a grouped argument\n\nSecond Group:\n -z BAZ, --baz BAZ another grouped argument\n") | |
|
90 | 96 | assert_equal(getattr(magic_foo3, 'argcmd_name', None), None) |
|
91 | 97 | assert_equal(real_name(magic_foo3), 'foo3') |
|
92 | 98 | assert_equal(magic_foo3(None, ''), |
|
93 | 99 | argparse.Namespace(bar=None, baz=None, foo=None)) |
|
94 | 100 | assert hasattr(magic_foo3, 'has_arguments') |
|
95 | 101 | |
|
96 |
assert_equal(magic_foo4.__doc__, |
|
|
102 | assert_equal(magic_foo4.__doc__, f"::\n\n %foo4 [-f FOO]\n\n A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n") | |
|
97 | 103 | assert_equal(getattr(magic_foo4, 'argcmd_name', None), None) |
|
98 | 104 | assert_equal(real_name(magic_foo4), 'foo4') |
|
99 | 105 | assert_equal(magic_foo4(None, ''), argparse.Namespace()) |
|
100 | 106 | assert hasattr(magic_foo4, 'has_arguments') |
|
101 | 107 | |
|
102 |
assert_equal(magic_foo5.__doc__, |
|
|
108 | assert_equal(magic_foo5.__doc__, f"::\n\n %frobnicate [-f FOO]\n\n A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n") | |
|
103 | 109 | assert_equal(getattr(magic_foo5, 'argcmd_name', None), 'frobnicate') |
|
104 | 110 | assert_equal(real_name(magic_foo5), 'frobnicate') |
|
105 | 111 | assert_equal(magic_foo5(None, ''), argparse.Namespace(foo=None)) |
|
106 | 112 | assert hasattr(magic_foo5, 'has_arguments') |
|
107 | 113 | |
|
108 |
assert_equal(magic_magic_foo.__doc__, |
|
|
114 | assert_equal(magic_magic_foo.__doc__, f"::\n\n %magic_foo [-f FOO]\n\n A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n") | |
|
109 | 115 | assert_equal(getattr(magic_magic_foo, 'argcmd_name', None), None) |
|
110 | 116 | assert_equal(real_name(magic_magic_foo), 'magic_foo') |
|
111 | 117 | assert_equal(magic_magic_foo(None, ''), argparse.Namespace(foo=None)) |
|
112 | 118 | assert hasattr(magic_magic_foo, 'has_arguments') |
|
113 | 119 | |
|
114 |
assert_equal(foo.__doc__, |
|
|
120 | assert_equal(foo.__doc__, f"::\n\n %foo [-f FOO]\n\n A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n") | |
|
115 | 121 | assert_equal(getattr(foo, 'argcmd_name', None), None) |
|
116 | 122 | assert_equal(real_name(foo), 'foo') |
|
117 | 123 | assert_equal(foo(None, ''), argparse.Namespace(foo=None)) |
@@ -7,14 +7,15 b'' | |||
|
7 | 7 | |
|
8 | 8 | from collections import Counter, defaultdict, deque, OrderedDict |
|
9 | 9 | import os |
|
10 | import pytest | |
|
10 | 11 | import types |
|
11 | 12 | import string |
|
13 | import sys | |
|
12 | 14 | import unittest |
|
13 | 15 | |
|
14 | 16 | import nose.tools as nt |
|
15 | 17 | |
|
16 | 18 | from IPython.lib import pretty |
|
17 | from IPython.testing.decorators import skip_without | |
|
18 | 19 | |
|
19 | 20 | from io import StringIO |
|
20 | 21 | |
@@ -118,12 +119,12 b' def test_sets():' | |||
|
118 | 119 | yield nt.assert_equal, got_output, expected_output |
|
119 | 120 | |
|
120 | 121 | |
|
121 | @skip_without('xxlimited') | |
|
122 | 122 | def test_pprint_heap_allocated_type(): |
|
123 | 123 | """ |
|
124 | 124 | Test that pprint works for heap allocated types. |
|
125 | 125 | """ |
|
126 | import xxlimited | |
|
126 | module_name = "xxlimited" if sys.version_info < (3, 10) else "xxlimited_35" | |
|
127 | xxlimited = pytest.importorskip(module_name) | |
|
127 | 128 | output = pretty.pretty(xxlimited.Null) |
|
128 | 129 | nt.assert_equal(output, 'xxlimited.Null') |
|
129 | 130 |
General Comments 0
You need to be logged in to leave comments.
Login now