Show More
@@ -114,7 +114,7 b' class NamedInstanceMetaclass(type):' | |||||
114 | def __getitem__(cls, item): |
|
114 | def __getitem__(cls, item): | |
115 | return cls.get_instance(item) |
|
115 | return cls.get_instance(item) | |
116 |
|
116 | |||
117 |
class NamedInstanceClass( |
|
117 | class NamedInstanceClass(metaclass=NamedInstanceMetaclass): | |
118 | def __init__(self, name): |
|
118 | def __init__(self, name): | |
119 | if not hasattr(self.__class__, 'instances'): |
|
119 | if not hasattr(self.__class__, 'instances'): | |
120 | self.__class__.instances = {} |
|
120 | self.__class__.instances = {} | |
@@ -128,7 +128,7 b' class NamedInstanceClass(object, metaclass=NamedInstanceMetaclass):' | |||||
128 | def get_instance(cls, name): |
|
128 | def get_instance(cls, name): | |
129 | return cls.instances[name] |
|
129 | return cls.instances[name] | |
130 |
|
130 | |||
131 |
class KeyCompletable |
|
131 | class KeyCompletable: | |
132 | def __init__(self, things=()): |
|
132 | def __init__(self, things=()): | |
133 | self.things = things |
|
133 | self.things = things | |
134 |
|
134 | |||
@@ -155,7 +155,7 b' class TestCompleter(unittest.TestCase):' | |||||
155 | def test_custom_completion_error(self): |
|
155 | def test_custom_completion_error(self): | |
156 | """Test that errors from custom attribute completers are silenced.""" |
|
156 | """Test that errors from custom attribute completers are silenced.""" | |
157 | ip = get_ipython() |
|
157 | ip = get_ipython() | |
158 |
class A |
|
158 | class A: pass | |
159 | ip.user_ns['x'] = A() |
|
159 | ip.user_ns['x'] = A() | |
160 |
|
160 | |||
161 | @complete_object.register(A) |
|
161 | @complete_object.register(A) | |
@@ -190,11 +190,11 b' class TestCompleter(unittest.TestCase):' | |||||
190 | nt.assert_equal(text, k) |
|
190 | nt.assert_equal(text, k) | |
191 | nt.assert_equal(matches[0], latex_symbols[k]) |
|
191 | nt.assert_equal(matches[0], latex_symbols[k]) | |
192 | # Test a more complex line |
|
192 | # Test a more complex line | |
193 |
text, matches = ip.complete( |
|
193 | text, matches = ip.complete('print(\\alpha') | |
194 |
nt.assert_equal(text, |
|
194 | nt.assert_equal(text, '\\alpha') | |
195 | nt.assert_equal(matches[0], latex_symbols['\\alpha']) |
|
195 | nt.assert_equal(matches[0], latex_symbols['\\alpha']) | |
196 | # Test multiple matching latex symbols |
|
196 | # Test multiple matching latex symbols | |
197 |
text, matches = ip.complete( |
|
197 | text, matches = ip.complete('\\al') | |
198 | nt.assert_in('\\alpha', matches) |
|
198 | nt.assert_in('\\alpha', matches) | |
199 | nt.assert_in('\\aleph', matches) |
|
199 | nt.assert_in('\\aleph', matches) | |
200 |
|
200 | |||
@@ -313,7 +313,7 b' class TestCompleter(unittest.TestCase):' | |||||
313 | # Now check with a function call |
|
313 | # Now check with a function call | |
314 | cmd = 'a = f("%s' % prefix |
|
314 | cmd = 'a = f("%s' % prefix | |
315 | c = ip.complete(prefix, cmd)[1] |
|
315 | c = ip.complete(prefix, cmd)[1] | |
316 |
comp = |
|
316 | comp = {prefix+s for s in suffixes} | |
317 | nt.assert_true(comp.issubset(set(c))) |
|
317 | nt.assert_true(comp.issubset(set(c))) | |
318 |
|
318 | |||
319 |
|
319 | |||
@@ -528,14 +528,14 b' class TestCompleter(unittest.TestCase):' | |||||
528 |
|
528 | |||
529 |
|
529 | |||
530 | def test_get__all__entries_ok(self): |
|
530 | def test_get__all__entries_ok(self): | |
531 |
class A |
|
531 | class A: | |
532 | __all__ = ['x', 1] |
|
532 | __all__ = ['x', 1] | |
533 | words = completer.get__all__entries(A()) |
|
533 | words = completer.get__all__entries(A()) | |
534 | nt.assert_equal(words, ['x']) |
|
534 | nt.assert_equal(words, ['x']) | |
535 |
|
535 | |||
536 |
|
536 | |||
537 | def test_get__all__entries_no__all__ok(self): |
|
537 | def test_get__all__entries_no__all__ok(self): | |
538 |
class A |
|
538 | class A: | |
539 | pass |
|
539 | pass | |
540 | words = completer.get__all__entries(A()) |
|
540 | words = completer.get__all__entries(A()) | |
541 | nt.assert_equal(words, []) |
|
541 | nt.assert_equal(words, []) | |
@@ -907,7 +907,7 b' class TestCompleter(unittest.TestCase):' | |||||
907 | ip = get_ipython() |
|
907 | ip = get_ipython() | |
908 | complete = ip.Completer.complete |
|
908 | complete = ip.Completer.complete | |
909 |
|
909 | |||
910 |
ip.user_ns['d'] = { |
|
910 | ip.user_ns['d'] = {'a\u05d0': None} | |
911 |
|
911 | |||
912 | # query using escape |
|
912 | # query using escape | |
913 | if sys.platform != 'win32': |
|
913 | if sys.platform != 'win32': | |
@@ -917,7 +917,7 b' class TestCompleter(unittest.TestCase):' | |||||
917 |
|
917 | |||
918 | # query using character |
|
918 | # query using character | |
919 | _, matches = complete(line_buffer="d['a\u05d0") |
|
919 | _, matches = complete(line_buffer="d['a\u05d0") | |
920 |
nt.assert_in( |
|
920 | nt.assert_in("a\u05d0", matches) | |
921 |
|
921 | |||
922 | with greedy_completion(): |
|
922 | with greedy_completion(): | |
923 | # query using escape |
|
923 | # query using escape | |
@@ -926,7 +926,7 b' class TestCompleter(unittest.TestCase):' | |||||
926 |
|
926 | |||
927 | # query using character |
|
927 | # query using character | |
928 | _, matches = complete(line_buffer="d['a\u05d0") |
|
928 | _, matches = complete(line_buffer="d['a\u05d0") | |
929 |
nt.assert_in( |
|
929 | nt.assert_in("d['a\u05d0']", matches) | |
930 |
|
930 | |||
931 |
|
931 | |||
932 |
|
932 |
General Comments 0
You need to be logged in to leave comments.
Login now