Show More
@@ -15,13 +15,13 b' jobs:' | |||||
15 | strategy: |
|
15 | strategy: | |
16 | matrix: |
|
16 | matrix: | |
17 | os: [ubuntu-latest] |
|
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 | # Test all on ubuntu, test ends on macos |
|
19 | # Test all on ubuntu, test ends on macos | |
20 | include: |
|
20 | include: | |
21 | - os: macos-latest |
|
21 | - os: macos-latest | |
22 | python-version: "3.7" |
|
22 | python-version: "3.7" | |
23 | - os: macos-latest |
|
23 | - os: macos-latest | |
24 |
python-version: "3. |
|
24 | python-version: "3.10" | |
25 |
|
25 | |||
26 | steps: |
|
26 | steps: | |
27 | - uses: actions/checkout@v2 |
|
27 | - uses: actions/checkout@v2 |
@@ -305,13 +305,13 b' def find_file(obj) -> str:' | |||||
305 | fname = None |
|
305 | fname = None | |
306 | try: |
|
306 | try: | |
307 | fname = inspect.getabsfile(obj) |
|
307 | fname = inspect.getabsfile(obj) | |
308 | except TypeError: |
|
308 | except (OSError, TypeError): | |
309 | # For an instance, the file that matters is where its class was |
|
309 | # For an instance, the file that matters is where its class was | |
310 | # declared. |
|
310 | # declared. | |
311 | if hasattr(obj, '__class__'): |
|
311 | if hasattr(obj, '__class__'): | |
312 | try: |
|
312 | try: | |
313 | fname = inspect.getabsfile(obj.__class__) |
|
313 | fname = inspect.getabsfile(obj.__class__) | |
314 | except TypeError: |
|
314 | except (OSError, TypeError): | |
315 | # Can happen for builtins |
|
315 | # Can happen for builtins | |
316 | pass |
|
316 | pass | |
317 | except: |
|
317 | except: |
@@ -12,6 +12,7 b' import unittest' | |||||
12 | from contextlib import contextmanager |
|
12 | from contextlib import contextmanager | |
13 |
|
13 | |||
14 | import nose.tools as nt |
|
14 | import nose.tools as nt | |
|
15 | import pytest | |||
15 |
|
16 | |||
16 | from traitlets.config.loader import Config |
|
17 | from traitlets.config.loader import Config | |
17 | from IPython import get_ipython |
|
18 | from IPython import get_ipython | |
@@ -29,6 +30,15 b' from IPython.core.completer import (' | |||||
29 | ) |
|
30 | ) | |
30 | from nose.tools import assert_in, assert_not_in |
|
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 | # Test functions |
|
43 | # Test functions | |
34 | # ----------------------------------------------------------------------------- |
|
44 | # ----------------------------------------------------------------------------- | |
@@ -381,6 +391,8 b' class TestCompleter(unittest.TestCase):' | |||||
381 | matches = c.all_completions("TestCl") |
|
391 | matches = c.all_completions("TestCl") | |
382 | assert matches == ['TestClass'], jedi_status |
|
392 | assert matches == ['TestClass'], jedi_status | |
383 | matches = c.all_completions("TestClass.") |
|
393 | matches = c.all_completions("TestClass.") | |
|
394 | if jedi_status and jedi_issue: | |||
|
395 | continue | |||
384 | assert len(matches) > 2, jedi_status |
|
396 | assert len(matches) > 2, jedi_status | |
385 | matches = c.all_completions("TestClass.a") |
|
397 | matches = c.all_completions("TestClass.a") | |
386 | assert matches == ['TestClass.a', 'TestClass.a1'], jedi_status |
|
398 | assert matches == ['TestClass.a', 'TestClass.a1'], jedi_status | |
@@ -435,6 +447,7 b' class TestCompleter(unittest.TestCase):' | |||||
435 | "encoding" in c.signature |
|
447 | "encoding" in c.signature | |
436 | ), "Signature of function was not found by completer" |
|
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 | def test_deduplicate_completions(self): |
|
451 | def test_deduplicate_completions(self): | |
439 | """ |
|
452 | """ | |
440 | Test that completions are correctly deduplicated (even if ranges are not the same) |
|
453 | Test that completions are correctly deduplicated (even if ranges are not the same) |
@@ -7,6 +7,7 b'' | |||||
7 | #----------------------------------------------------------------------------- |
|
7 | #----------------------------------------------------------------------------- | |
8 |
|
8 | |||
9 | import argparse |
|
9 | import argparse | |
|
10 | import sys | |||
10 | from nose.tools import assert_equal |
|
11 | from nose.tools import assert_equal | |
11 |
|
12 | |||
12 | from IPython.core.magic_arguments import (argument, argument_group, kwds, |
|
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 | def test_magic_arguments(): |
|
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 | assert_equal(getattr(magic_foo1, 'argcmd_name', None), None) |
|
84 | assert_equal(getattr(magic_foo1, 'argcmd_name', None), None) | |
79 | assert_equal(real_name(magic_foo1), 'foo1') |
|
85 | assert_equal(real_name(magic_foo1), 'foo1') | |
80 | assert_equal(magic_foo1(None, ''), argparse.Namespace(foo=None)) |
|
86 | assert_equal(magic_foo1(None, ''), argparse.Namespace(foo=None)) | |
@@ -86,32 +92,32 b' def test_magic_arguments():' | |||||
86 | assert_equal(magic_foo2(None, ''), argparse.Namespace()) |
|
92 | assert_equal(magic_foo2(None, ''), argparse.Namespace()) | |
87 | assert hasattr(magic_foo2, 'has_arguments') |
|
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 | assert_equal(getattr(magic_foo3, 'argcmd_name', None), None) |
|
96 | assert_equal(getattr(magic_foo3, 'argcmd_name', None), None) | |
91 | assert_equal(real_name(magic_foo3), 'foo3') |
|
97 | assert_equal(real_name(magic_foo3), 'foo3') | |
92 | assert_equal(magic_foo3(None, ''), |
|
98 | assert_equal(magic_foo3(None, ''), | |
93 | argparse.Namespace(bar=None, baz=None, foo=None)) |
|
99 | argparse.Namespace(bar=None, baz=None, foo=None)) | |
94 | assert hasattr(magic_foo3, 'has_arguments') |
|
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 | assert_equal(getattr(magic_foo4, 'argcmd_name', None), None) |
|
103 | assert_equal(getattr(magic_foo4, 'argcmd_name', None), None) | |
98 | assert_equal(real_name(magic_foo4), 'foo4') |
|
104 | assert_equal(real_name(magic_foo4), 'foo4') | |
99 | assert_equal(magic_foo4(None, ''), argparse.Namespace()) |
|
105 | assert_equal(magic_foo4(None, ''), argparse.Namespace()) | |
100 | assert hasattr(magic_foo4, 'has_arguments') |
|
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 | assert_equal(getattr(magic_foo5, 'argcmd_name', None), 'frobnicate') |
|
109 | assert_equal(getattr(magic_foo5, 'argcmd_name', None), 'frobnicate') | |
104 | assert_equal(real_name(magic_foo5), 'frobnicate') |
|
110 | assert_equal(real_name(magic_foo5), 'frobnicate') | |
105 | assert_equal(magic_foo5(None, ''), argparse.Namespace(foo=None)) |
|
111 | assert_equal(magic_foo5(None, ''), argparse.Namespace(foo=None)) | |
106 | assert hasattr(magic_foo5, 'has_arguments') |
|
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 | assert_equal(getattr(magic_magic_foo, 'argcmd_name', None), None) |
|
115 | assert_equal(getattr(magic_magic_foo, 'argcmd_name', None), None) | |
110 | assert_equal(real_name(magic_magic_foo), 'magic_foo') |
|
116 | assert_equal(real_name(magic_magic_foo), 'magic_foo') | |
111 | assert_equal(magic_magic_foo(None, ''), argparse.Namespace(foo=None)) |
|
117 | assert_equal(magic_magic_foo(None, ''), argparse.Namespace(foo=None)) | |
112 | assert hasattr(magic_magic_foo, 'has_arguments') |
|
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 | assert_equal(getattr(foo, 'argcmd_name', None), None) |
|
121 | assert_equal(getattr(foo, 'argcmd_name', None), None) | |
116 | assert_equal(real_name(foo), 'foo') |
|
122 | assert_equal(real_name(foo), 'foo') | |
117 | assert_equal(foo(None, ''), argparse.Namespace(foo=None)) |
|
123 | assert_equal(foo(None, ''), argparse.Namespace(foo=None)) |
@@ -7,14 +7,15 b'' | |||||
7 |
|
7 | |||
8 | from collections import Counter, defaultdict, deque, OrderedDict |
|
8 | from collections import Counter, defaultdict, deque, OrderedDict | |
9 | import os |
|
9 | import os | |
|
10 | import pytest | |||
10 | import types |
|
11 | import types | |
11 | import string |
|
12 | import string | |
|
13 | import sys | |||
12 | import unittest |
|
14 | import unittest | |
13 |
|
15 | |||
14 | import nose.tools as nt |
|
16 | import nose.tools as nt | |
15 |
|
17 | |||
16 | from IPython.lib import pretty |
|
18 | from IPython.lib import pretty | |
17 | from IPython.testing.decorators import skip_without |
|
|||
18 |
|
19 | |||
19 | from io import StringIO |
|
20 | from io import StringIO | |
20 |
|
21 | |||
@@ -118,12 +119,12 b' def test_sets():' | |||||
118 | yield nt.assert_equal, got_output, expected_output |
|
119 | yield nt.assert_equal, got_output, expected_output | |
119 |
|
120 | |||
120 |
|
121 | |||
121 | @skip_without('xxlimited') |
|
|||
122 | def test_pprint_heap_allocated_type(): |
|
122 | def test_pprint_heap_allocated_type(): | |
123 | """ |
|
123 | """ | |
124 | Test that pprint works for heap allocated types. |
|
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 | output = pretty.pretty(xxlimited.Null) |
|
128 | output = pretty.pretty(xxlimited.Null) | |
128 | nt.assert_equal(output, 'xxlimited.Null') |
|
129 | nt.assert_equal(output, 'xxlimited.Null') | |
129 |
|
130 |
General Comments 0
You need to be logged in to leave comments.
Login now