diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-04 15:54:33 (GMT) |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-04 15:54:33 (GMT) |
| commit | 185fae73c67aad4d59598d293f1f39f9940c9266 (patch) | |
| tree | d806efe8e582337af426e9aafeebdf67a023b031 | |
| parent | c529a07cf465e5c3af5714912c5153eea8c2b4ee (diff) | |
| download | cpython-185fae73c67aad4d59598d293f1f39f9940c9266.zip cpython-185fae73c67aad4d59598d293f1f39f9940c9266.tar.gz cpython-185fae73c67aad4d59598d293f1f39f9940c9266.tar.bz2 | |
Merged revisions 83719 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r83719 | antoine.pitrou | 2010-08-04 17:43:16 +0200 (mer., 04 août 2010) | 4 lines
Issue #9496: Provide a test suite for the rlcompleter module. Patch by
Michele Orrù.
........
| -rw-r--r-- | Lib/test/test_rlcompleter.py | 73 | ||||
| -rw-r--r-- | Lib/test/test_sundry.py | 1 | ||||
| -rw-r--r-- | Misc/ACKS | 1 | ||||
| -rw-r--r-- | Misc/NEWS | 3 |
4 files changed, 77 insertions, 1 deletions
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py new file mode 100644 index 0000000..1c5fcc6 --- /dev/null +++ b/Lib/test/test_rlcompleter.py @@ -0,0 +1,73 @@ +from test import test_support as support +import unittest +import __builtin__ as builtins +import rlcompleter + +class CompleteMe(object): + """ Trivial class used in testing rlcompleter.Completer. """ + spam = 1 + + +class TestRlcompleter(unittest.TestCase): + def setUp(self): + self.stdcompleter = rlcompleter.Completer() + self.completer = rlcompleter.Completer(dict(spam=int, + egg=str, + CompleteMe=CompleteMe)) + + # forces stdcompleter to bind builtins namespace + self.stdcompleter.complete('', 0) + + def test_namespace(self): + class A(dict): + pass + class B(list): + pass + + self.assertTrue(self.stdcompleter.use_main_ns) + self.assertFalse(self.completer.use_main_ns) + self.assertFalse(rlcompleter.Completer(A()).use_main_ns) + self.assertRaises(TypeError, rlcompleter.Completer, B((1,))) + + def test_global_matches(self): + # test with builtins namespace + self.assertEqual(self.stdcompleter.global_matches('di'), + [x+'(' for x in dir(builtins) if x.startswith('di')]) + self.assertEqual(self.stdcompleter.global_matches('st'), + [x+'(' for x in dir(builtins) if x.startswith('st')]) + self.assertEqual(self.stdcompleter.global_matches('akaksajadhak'), []) + + # test with a customized namespace + self.assertEqual(self.completer.global_matches('CompleteM'), + ['CompleteMe(']) + self.assertEqual(self.completer.global_matches('eg'), + ['egg(']) + # XXX: see issue5256 + self.assertEqual(self.completer.global_matches('CompleteM'), + ['CompleteMe(']) + + def test_attr_matches(self): + # test with builtins namespace + self.assertEqual(self.stdcompleter.attr_matches('str.s'), + ['str.{}('.format(x) for x in dir(str) + if x.startswith('s')]) + self.assertEqual(self.stdcompleter.attr_matches('tuple.foospamegg'), []) + + # test with a customized namespace + self.assertEqual(self.completer.attr_matches('CompleteMe.sp'), + ['CompleteMe.spam']) + self.assertEqual(self.completer.attr_matches('Completeme.egg'), []) + + CompleteMe.me = CompleteMe + self.assertEqual(self.completer.attr_matches('CompleteMe.me.me.sp'), + ['CompleteMe.me.me.spam']) + self.assertEqual(self.completer.attr_matches('egg.s'), + ['egg.{}('.format(x) for x in dir(str) + if x.startswith('s')]) + +def test_main(): + support.run_unittest(TestRlcompleter) + + +if __name__ == '__main__': + test_main() diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py index 3aade6d..6e2b797 100644 --- a/Lib/test/test_sundry.py +++ b/Lib/test/test_sundry.py @@ -65,7 +65,6 @@ class TestUntestedModules(unittest.TestCase): import pstats import py_compile import rexec - import rlcompleter import sched import sndhdr import statvfs @@ -575,6 +575,7 @@ Grant Olson Piet van Oostrum Jason Orendorff Douglas Orr +Michele Orrù Denis S. Otkidach Michael Otteneder R. M. Oudkerk @@ -185,6 +185,9 @@ Build Tests ----- +- Issue #9496: Provide a test suite for the rlcompleter module. Patch by + Michele Orrù. + - Issue #8605: Skip test_gdb if Python is compiled with optimizations. Documentation |
