|
1 |
| -import collections |
2 | 1 | from itertools import islice
|
| 2 | +import collections |
| 3 | +import inspect |
3 | 4 | import os
|
4 | 5 | import shutil
|
5 | 6 | import socket
|
6 | 7 | import tempfile
|
7 | 8 | from six.moves import range
|
| 9 | +import sys |
8 | 10 |
|
9 | 11 | try:
|
10 | 12 | import unittest2 as unittest
|
|
15 | 17 | from bpython import config, repl, cli, autocomplete
|
16 | 18 | from bpython.test import MagicIterMock, mock, FixLanguageTestCase as TestCase
|
17 | 19 |
|
| 20 | +pypy = 'PyPy' in sys.version |
18 | 21 |
|
19 | 22 | def setup_config(conf):
|
20 | 23 | config_struct = config.Struct()
|
@@ -230,21 +233,25 @@ def assert_get_source_error_for_current_function(self, func, msg):
|
230 | 233 |
|
231 | 234 | def test_current_function(self):
|
232 | 235 | self.set_input_line('INPUTLINE')
|
233 |
| - self.repl.current_func = collections.MutableSet.add |
234 |
| - self.assertIn("Add an element.", |
| 236 | + self.repl.current_func = inspect.getsource |
| 237 | + self.assertIn("text of the source code", |
235 | 238 | self.repl.get_source_of_current_name())
|
236 | 239 |
|
237 | 240 | self.assert_get_source_error_for_current_function(
|
238 |
| - collections.defaultdict.copy, "No source code found for INPUTLINE") |
| 241 | + [], "No source code found for INPUTLINE") |
239 | 242 |
|
240 | 243 | self.assert_get_source_error_for_current_function(
|
241 |
| - collections.defaultdict, "could not find class definition") |
| 244 | + list.pop, "No source code found for INPUTLINE") |
242 | 245 |
|
| 246 | + @unittest.skipIf(pypy, 'different errors for PyPy') |
| 247 | + def test_current_function_cpython(self): |
| 248 | + self.set_input_line('INPUTLINE') |
243 | 249 | self.assert_get_source_error_for_current_function(
|
244 |
| - [], "No source code found for INPUTLINE") |
245 |
| - |
| 250 | + collections.defaultdict.copy, "No source code found for INPUTLINE") |
246 | 251 | self.assert_get_source_error_for_current_function(
|
247 |
| - list.pop, "No source code found for INPUTLINE") |
| 252 | + collections.defaultdict, "could not find class definition") |
| 253 | + |
| 254 | + |
248 | 255 |
|
249 | 256 | def test_current_line(self):
|
250 | 257 | self.repl.interp.locals['a'] = socket.socket
|
|
0 commit comments