PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/pypy/module/sys/test/test_sysmodule.py

https://bitbucket.org/pwaller/pypy
Python | 718 lines | 697 code | 20 blank | 1 comment | 14 complexity | 5e4c747f350af6adfd35c06a45ec567d MD5 | raw file
  1. # -*- coding: iso-8859-1 -*-
  2. import autopath
  3. from pypy.conftest import option, gettestobjspace
  4. from py.test import raises
  5. from pypy.interpreter.gateway import app2interp_temp
  6. import sys
  7. def test_stdin_exists(space):
  8. space.sys.get('stdin')
  9. space.sys.get('__stdin__')
  10. def test_stdout_exists(space):
  11. space.sys.get('stdout')
  12. space.sys.get('__stdout__')
  13. class AppTestAppSysTests:
  14. def setup_class(cls):
  15. cls.w_appdirect = cls.space.wrap(option.runappdirect)
  16. cls.w_filesystemenc = cls.space.wrap(sys.getfilesystemencoding())
  17. def test_sys_in_modules(self):
  18. import sys
  19. modules = sys.modules
  20. assert 'sys' in modules, ( "An entry for sys "
  21. "is not in sys.modules.")
  22. sys2 = sys.modules['sys']
  23. assert sys is sys2, "import sys is not sys.modules[sys]."
  24. def test_builtin_in_modules(self):
  25. import sys
  26. modules = sys.modules
  27. assert '__builtin__' in modules, ( "An entry for __builtin__ "
  28. "is not in sys.modules.")
  29. import __builtin__
  30. builtin2 = sys.modules['__builtin__']
  31. assert __builtin__ is builtin2, ( "import __builtin__ "
  32. "is not sys.modules[__builtin__].")
  33. def test_builtin_module_names(self):
  34. import sys
  35. names = sys.builtin_module_names
  36. assert 'sys' in names, (
  37. "sys is not listed as a builtin module.")
  38. assert '__builtin__' in names, (
  39. "__builtin__ is not listed as a builtin module.")
  40. def test_sys_exc_info(self):
  41. try:
  42. raise Exception
  43. except Exception,e:
  44. import sys
  45. exc_type,exc_val,tb = sys.exc_info()
  46. try:
  47. raise Exception # 5 lines below the previous one
  48. except Exception,e2:
  49. exc_type2,exc_val2,tb2 = sys.exc_info()
  50. assert exc_type ==Exception
  51. assert exc_val ==e
  52. assert exc_type2 ==Exception
  53. assert exc_val2 ==e2
  54. assert tb2.tb_lineno - tb.tb_lineno == 5
  55. def test_dynamic_attributes(self):
  56. try:
  57. raise Exception
  58. except Exception,e:
  59. import sys
  60. exc_type = sys.exc_type
  61. exc_val = sys.exc_value
  62. tb = sys.exc_traceback
  63. try:
  64. raise Exception # 7 lines below the previous one
  65. except Exception,e2:
  66. exc_type2 = sys.exc_type
  67. exc_val2 = sys.exc_value
  68. tb2 = sys.exc_traceback
  69. assert exc_type ==Exception
  70. assert exc_val ==e
  71. assert exc_type2 ==Exception
  72. assert exc_val2 ==e2
  73. assert tb2.tb_lineno - tb.tb_lineno == 7
  74. def test_exc_info_normalization(self):
  75. import sys
  76. try:
  77. 1/0
  78. except ZeroDivisionError:
  79. etype, val, tb = sys.exc_info()
  80. assert isinstance(val, etype)
  81. else:
  82. raise AssertionError, "ZeroDivisionError not caught"
  83. def test_io(self):
  84. import sys
  85. assert isinstance(sys.__stdout__, file)
  86. assert isinstance(sys.__stderr__, file)
  87. assert isinstance(sys.__stdin__, file)
  88. if self.appdirect and not isinstance(sys.stdin, file):
  89. return
  90. assert isinstance(sys.stdout, file)
  91. assert isinstance(sys.stderr, file)
  92. assert isinstance(sys.stdin, file)
  93. def test_getfilesystemencoding(self):
  94. import sys
  95. assert sys.getfilesystemencoding() == self.filesystemenc
  96. def test_float_info(self):
  97. import sys
  98. fi = sys.float_info
  99. assert isinstance(fi.epsilon, float)
  100. assert isinstance(fi.dig, int)
  101. assert isinstance(fi.mant_dig, int)
  102. assert isinstance(fi.max, float)
  103. assert isinstance(fi.max_exp, int)
  104. assert isinstance(fi.max_10_exp, int)
  105. assert isinstance(fi.min, float)
  106. assert isinstance(fi.min_exp, int)
  107. assert isinstance(fi.min_10_exp, int)
  108. assert isinstance(fi.radix, int)
  109. assert isinstance(fi.rounds, int)
  110. def test_long_info(self):
  111. import sys
  112. li = sys.long_info
  113. assert isinstance(li.bits_per_digit, int)
  114. assert isinstance(li.sizeof_digit, int)
  115. class AppTestSysModulePortedFromCPython:
  116. def setup_class(cls):
  117. cls.w_appdirect = cls.space.wrap(option.runappdirect)
  118. def test_original_displayhook(self):
  119. import sys, cStringIO, __builtin__
  120. savestdout = sys.stdout
  121. out = cStringIO.StringIO()
  122. sys.stdout = out
  123. dh = sys.__displayhook__
  124. raises(TypeError, dh)
  125. if hasattr(__builtin__, "_"):
  126. del __builtin__._
  127. dh(None)
  128. assert out.getvalue() == ""
  129. assert not hasattr(__builtin__, "_")
  130. dh("hello")
  131. assert out.getvalue() == "'hello'\n"
  132. assert __builtin__._ == "hello"
  133. del sys.stdout
  134. raises(RuntimeError, dh, 42)
  135. sys.stdout = savestdout
  136. def test_lost_displayhook(self):
  137. import sys
  138. olddisplayhook = sys.displayhook
  139. del sys.displayhook
  140. code = compile("42", "<string>", "single")
  141. raises(RuntimeError, eval, code)
  142. sys.displayhook = olddisplayhook
  143. def test_custom_displayhook(self):
  144. import sys
  145. olddisplayhook = sys.displayhook
  146. def baddisplayhook(obj):
  147. raise ValueError
  148. sys.displayhook = baddisplayhook
  149. code = compile("42", "<string>", "single")
  150. raises(ValueError, eval, code)
  151. sys.displayhook = olddisplayhook
  152. def test_original_excepthook(self):
  153. import sys, cStringIO
  154. savestderr = sys.stderr
  155. err = cStringIO.StringIO()
  156. sys.stderr = err
  157. eh = sys.__excepthook__
  158. raises(TypeError, eh)
  159. try:
  160. raise ValueError(42)
  161. except ValueError, exc:
  162. eh(*sys.exc_info())
  163. sys.stderr = savestderr
  164. assert err.getvalue().endswith("ValueError: 42\n")
  165. def test_excepthook_failsafe_path(self):
  166. import traceback
  167. original_print_exception = traceback.print_exception
  168. import sys, cStringIO
  169. savestderr = sys.stderr
  170. err = cStringIO.StringIO()
  171. sys.stderr = err
  172. try:
  173. traceback.print_exception = "foo"
  174. eh = sys.__excepthook__
  175. try:
  176. raise ValueError(42)
  177. except ValueError, exc:
  178. eh(*sys.exc_info())
  179. finally:
  180. traceback.print_exception = original_print_exception
  181. sys.stderr = savestderr
  182. assert err.getvalue() == "ValueError: 42\n"
  183. # FIXME: testing the code for a lost or replaced excepthook in
  184. # Python/pythonrun.c::PyErr_PrintEx() is tricky.
  185. def test_exc_clear(self):
  186. import sys
  187. raises(TypeError, sys.exc_clear, 42)
  188. # Verify that exc_info is present and matches exc, then clear it, and
  189. # check that it worked.
  190. def clear_check(exc):
  191. typ, value, traceback = sys.exc_info()
  192. assert typ is not None
  193. assert value is exc
  194. assert traceback is not None
  195. sys.exc_clear()
  196. typ, value, traceback = sys.exc_info()
  197. assert typ is None
  198. assert value is None
  199. assert traceback is None
  200. def clear():
  201. try:
  202. raise ValueError, 42
  203. except ValueError, exc:
  204. clear_check(exc)
  205. # Raise an exception and check that it can be cleared
  206. clear()
  207. # Verify that a frame currently handling an exception is
  208. # unaffected by calling exc_clear in a nested frame.
  209. try:
  210. raise ValueError, 13
  211. except ValueError, exc:
  212. typ1, value1, traceback1 = sys.exc_info()
  213. clear()
  214. typ2, value2, traceback2 = sys.exc_info()
  215. assert typ1 is typ2
  216. assert value1 is exc
  217. assert value1 is value2
  218. assert traceback1 is traceback2
  219. # Check that an exception can be cleared outside of an except block
  220. clear_check(exc)
  221. def test_exit(self):
  222. import sys
  223. raises(TypeError, sys.exit, 42, 42)
  224. # call without argument
  225. try:
  226. sys.exit(0)
  227. except SystemExit, exc:
  228. assert exc.code == 0
  229. except:
  230. raise AssertionError, "wrong exception"
  231. else:
  232. raise AssertionError, "no exception"
  233. # call with tuple argument with one entry
  234. # entry will be unpacked
  235. try:
  236. sys.exit(42)
  237. except SystemExit, exc:
  238. assert exc.code == 42
  239. except:
  240. raise AssertionError, "wrong exception"
  241. else:
  242. raise AssertionError, "no exception"
  243. # call with integer argument
  244. try:
  245. sys.exit((42,))
  246. except SystemExit, exc:
  247. assert exc.code == 42
  248. except:
  249. raise AssertionError, "wrong exception"
  250. else:
  251. raise AssertionError, "no exception"
  252. # call with string argument
  253. try:
  254. sys.exit("exit")
  255. except SystemExit, exc:
  256. assert exc.code == "exit"
  257. except:
  258. raise AssertionError, "wrong exception"
  259. else:
  260. raise AssertionError, "no exception"
  261. # call with tuple argument with two entries
  262. try:
  263. sys.exit((17, 23))
  264. except SystemExit, exc:
  265. assert exc.code == (17, 23)
  266. except:
  267. raise AssertionError, "wrong exception"
  268. else:
  269. raise AssertionError, "no exception"
  270. def test_getdefaultencoding(self):
  271. import sys
  272. raises(TypeError, sys.getdefaultencoding, 42)
  273. # can't check more than the type, as the user might have changed it
  274. assert isinstance(sys.getdefaultencoding(), str)
  275. def test_setdefaultencoding(self):
  276. import sys
  277. if self.appdirect:
  278. skip("not worth running appdirect")
  279. encoding = sys.getdefaultencoding()
  280. try:
  281. sys.setdefaultencoding("ascii")
  282. assert sys.getdefaultencoding() == 'ascii'
  283. raises(UnicodeDecodeError, unicode, '\x80')
  284. sys.setdefaultencoding("latin-1")
  285. assert sys.getdefaultencoding() == 'latin-1'
  286. assert unicode('\x80') == u'\u0080'
  287. finally:
  288. sys.setdefaultencoding(encoding)
  289. # testing sys.settrace() is done in test_trace.py
  290. # testing sys.setprofile() is done in test_profile.py
  291. def test_setcheckinterval(self):
  292. import sys
  293. raises(TypeError, sys.setcheckinterval)
  294. orig = sys.getcheckinterval()
  295. for n in 0, 100, 120, orig: # orig last to restore starting state
  296. sys.setcheckinterval(n)
  297. assert sys.getcheckinterval() == n
  298. def test_recursionlimit(self):
  299. import sys
  300. raises(TypeError, sys.getrecursionlimit, 42)
  301. oldlimit = sys.getrecursionlimit()
  302. raises(TypeError, sys.setrecursionlimit)
  303. raises(ValueError, sys.setrecursionlimit, -42)
  304. sys.setrecursionlimit(10000)
  305. assert sys.getrecursionlimit() == 10000
  306. sys.setrecursionlimit(oldlimit)
  307. def test_getwindowsversion(self):
  308. import sys
  309. if hasattr(sys, "getwindowsversion"):
  310. v = sys.getwindowsversion()
  311. assert isinstance(v, tuple)
  312. assert len(v) == 5
  313. assert isinstance(v[0], int)
  314. assert isinstance(v[1], int)
  315. assert isinstance(v[2], int)
  316. assert isinstance(v[3], int)
  317. assert isinstance(v[4], str)
  318. assert v[0] == v.major
  319. assert v[1] == v.minor
  320. assert v[2] == v.build
  321. assert v[3] == v.platform
  322. assert v[4] == v.service_pack
  323. assert isinstance(v.service_pack_minor, int)
  324. assert isinstance(v.service_pack_major, int)
  325. assert isinstance(v.suite_mask, int)
  326. assert isinstance(v.product_type, int)
  327. # This is how platform.py calls it. Make sure tuple still has 5
  328. # elements
  329. maj, min, buildno, plat, csd = sys.getwindowsversion()
  330. def test_winver(self):
  331. import sys
  332. if hasattr(sys, "winver"):
  333. assert sys.winver == sys.version[:3]
  334. def test_dlopenflags(self):
  335. import sys
  336. if hasattr(sys, "setdlopenflags"):
  337. assert hasattr(sys, "getdlopenflags")
  338. raises(TypeError, sys.getdlopenflags, 42)
  339. oldflags = sys.getdlopenflags()
  340. raises(TypeError, sys.setdlopenflags)
  341. sys.setdlopenflags(oldflags+1)
  342. assert sys.getdlopenflags() == oldflags+1
  343. sys.setdlopenflags(oldflags)
  344. def test_refcount(self):
  345. import sys
  346. if not hasattr(sys, "getrefcount"):
  347. skip('Reference counting is not implemented.')
  348. raises(TypeError, sys.getrefcount)
  349. c = sys.getrefcount(None)
  350. n = None
  351. assert sys.getrefcount(None) == c+1
  352. del n
  353. assert sys.getrefcount(None) == c
  354. if hasattr(sys, "gettotalrefcount"):
  355. assert isinstance(sys.gettotalrefcount(), int)
  356. def test_getframe(self):
  357. import sys
  358. raises(TypeError, sys._getframe, 42, 42)
  359. raises(ValueError, sys._getframe, 2000000000)
  360. assert sys._getframe().f_code.co_name == 'test_getframe'
  361. #assert (
  362. # TestSysModule.test_getframe.im_func.func_code \
  363. # is sys._getframe().f_code
  364. #)
  365. def test_getframe_in_returned_func(self):
  366. import sys
  367. def f():
  368. return g()
  369. def g():
  370. return sys._getframe(0)
  371. frame = f()
  372. assert frame.f_code.co_name == 'g'
  373. assert frame.f_back.f_code.co_name == 'f'
  374. assert frame.f_back.f_back.f_code.co_name == 'test_getframe_in_returned_func'
  375. def test_attributes(self):
  376. import sys
  377. assert sys.__name__ == 'sys'
  378. assert isinstance(sys.modules, dict)
  379. assert isinstance(sys.path, list)
  380. assert isinstance(sys.api_version, int)
  381. assert isinstance(sys.argv, list)
  382. assert sys.byteorder in ("little", "big")
  383. assert isinstance(sys.builtin_module_names, tuple)
  384. assert isinstance(sys.copyright, basestring)
  385. #assert isinstance(sys.exec_prefix, basestring) -- not present!
  386. assert isinstance(sys.executable, basestring)
  387. assert isinstance(sys.hexversion, int)
  388. assert isinstance(sys.maxint, int)
  389. assert isinstance(sys.maxsize, int)
  390. assert isinstance(sys.maxunicode, int)
  391. assert isinstance(sys.platform, basestring)
  392. #assert isinstance(sys.prefix, basestring) -- not present!
  393. assert isinstance(sys.version, basestring)
  394. assert isinstance(sys.warnoptions, list)
  395. vi = sys.version_info
  396. assert isinstance(vi, tuple)
  397. assert len(vi) == 5
  398. assert isinstance(vi[0], int)
  399. assert isinstance(vi[1], int)
  400. assert isinstance(vi[2], int)
  401. assert vi[3] in ("alpha", "beta", "candidate", "final")
  402. assert isinstance(vi[4], int)
  403. def test_settrace(self):
  404. import sys
  405. counts = []
  406. def trace(x, y, z):
  407. counts.append(None)
  408. def x():
  409. pass
  410. sys.settrace(trace)
  411. try:
  412. x()
  413. assert sys.gettrace() is trace
  414. finally:
  415. sys.settrace(None)
  416. assert len(counts) == 1
  417. def test_pypy_attributes(self):
  418. import sys
  419. assert isinstance(sys.pypy_objspaceclass, str)
  420. vi = sys.pypy_version_info
  421. assert isinstance(vi, tuple)
  422. assert len(vi) == 5
  423. assert isinstance(vi[0], int)
  424. assert isinstance(vi[1], int)
  425. assert isinstance(vi[2], int)
  426. assert vi[3] in ("alpha", "beta", "candidate", "dev", "final")
  427. assert isinstance(vi[4], int)
  428. def test_allattributes(self):
  429. import sys
  430. sys.__dict__ # check that we don't crash initializing any attribute
  431. def test_subversion(self):
  432. import sys
  433. assert sys.subversion == ('PyPy', '', '')
  434. def test__mercurial(self):
  435. import sys, re
  436. project, hgtag, hgid = sys._mercurial
  437. assert project == 'PyPy'
  438. # the tag or branch may be anything, including the empty string
  439. assert isinstance(hgtag, str)
  440. # the id is either nothing, or an id of 12 hash digits, with a possible
  441. # suffix of '+' if there are local modifications
  442. assert hgid == '' or re.match('[0-9a-f]{12}\+?', hgid)
  443. # the id should also show up in sys.version
  444. if hgid != '':
  445. assert hgid in sys.version
  446. def test_trace_exec_execfile(self):
  447. import sys
  448. found = []
  449. def do_tracing(f, *args):
  450. print f.f_code.co_filename, f.f_lineno, args
  451. if f.f_code.co_filename == 'foobar':
  452. found.append(args[0])
  453. return do_tracing
  454. co = compile("execfile('this-file-does-not-exist!')",
  455. 'foobar', 'exec')
  456. sys.settrace(do_tracing)
  457. try:
  458. exec co in {}
  459. except IOError:
  460. pass
  461. sys.settrace(None)
  462. assert found == ['call', 'line', 'exception', 'return']
  463. def test_float_repr_style(self):
  464. import sys
  465. # If this ever actually becomes a compilation option this test should
  466. # be changed.
  467. assert sys.float_repr_style == "short"
  468. class AppTestCurrentFrames:
  469. def test_current_frames(self):
  470. try:
  471. import thread
  472. except ImportError:
  473. pass
  474. else:
  475. skip('This test requires an intepreter without threads')
  476. import sys
  477. def f():
  478. return sys._current_frames()
  479. frames = f()
  480. assert frames.keys() == [0]
  481. assert frames[0].f_code.co_name in ('f', '?')
  482. class AppTestCurrentFramesWithThread(AppTestCurrentFrames):
  483. def setup_class(cls):
  484. cls.space = gettestobjspace(usemodules=('thread',))
  485. def test_current_frames(self):
  486. import sys
  487. import time
  488. import thread
  489. # XXX workaround for now: to prevent deadlocks, call
  490. # sys._current_frames() once before starting threads.
  491. # This is an issue in non-translated versions only.
  492. sys._current_frames()
  493. thread_id = thread.get_ident()
  494. def other_thread():
  495. print "thread started"
  496. lock2.release()
  497. lock1.acquire()
  498. lock1 = thread.allocate_lock()
  499. lock2 = thread.allocate_lock()
  500. lock1.acquire()
  501. lock2.acquire()
  502. thread.start_new_thread(other_thread, ())
  503. def f():
  504. lock2.acquire()
  505. return sys._current_frames()
  506. frames = f()
  507. lock1.release()
  508. thisframe = frames.pop(thread_id)
  509. assert thisframe.f_code.co_name in ('f', '?')
  510. assert len(frames) == 1
  511. _, other_frame = frames.popitem()
  512. assert other_frame.f_code.co_name in ('other_thread', '?')
  513. class AppTestSysExcInfoDirect:
  514. def setup_method(self, meth):
  515. self.checking = not option.runappdirect
  516. if self.checking:
  517. self.seen = []
  518. from pypy.module.sys import vm
  519. def exc_info_with_tb(*args):
  520. self.seen.append("n") # not optimized
  521. return self.old[0](*args)
  522. def exc_info_without_tb(*args):
  523. self.seen.append("y") # optimized
  524. return self.old[1](*args)
  525. self.old = [vm.exc_info_with_tb, vm.exc_info_without_tb]
  526. vm.exc_info_with_tb = exc_info_with_tb
  527. vm.exc_info_without_tb = exc_info_without_tb
  528. #
  529. from pypy.rlib import jit
  530. self.old2 = [jit.we_are_jitted]
  531. jit.we_are_jitted = lambda: True
  532. def teardown_method(self, meth):
  533. if self.checking:
  534. from pypy.module.sys import vm
  535. from pypy.rlib import jit
  536. vm.exc_info_with_tb = self.old[0]
  537. vm.exc_info_without_tb = self.old[1]
  538. jit.we_are_jitted = self.old2[0]
  539. #
  540. assert ''.join(self.seen) == meth.expected
  541. def test_returns_none(self):
  542. import sys
  543. assert sys.exc_info() == (None, None, None)
  544. assert sys.exc_info()[0] is None
  545. assert sys.exc_info()[1] is None
  546. assert sys.exc_info()[2] is None
  547. assert sys.exc_info()[:2] == (None, None)
  548. assert sys.exc_info()[:3] == (None, None, None)
  549. assert sys.exc_info()[0:2] == (None, None)
  550. assert sys.exc_info()[2:4] == (None,)
  551. test_returns_none.expected = 'nnnnnnnn'
  552. def test_returns_subscr(self):
  553. import sys
  554. e = KeyError("boom")
  555. try:
  556. raise e
  557. except:
  558. assert sys.exc_info()[0] is KeyError # y
  559. assert sys.exc_info()[1] is e # y
  560. assert sys.exc_info()[2] is not None # n
  561. assert sys.exc_info()[-3] is KeyError # y
  562. assert sys.exc_info()[-2] is e # y
  563. assert sys.exc_info()[-1] is not None # n
  564. test_returns_subscr.expected = 'yynyyn'
  565. def test_returns_slice_2(self):
  566. import sys
  567. e = KeyError("boom")
  568. try:
  569. raise e
  570. except:
  571. foo = sys.exc_info() # n
  572. assert sys.exc_info()[:0] == () # y
  573. assert sys.exc_info()[:1] == foo[:1] # y
  574. assert sys.exc_info()[:2] == foo[:2] # y
  575. assert sys.exc_info()[:3] == foo # n
  576. assert sys.exc_info()[:4] == foo # n
  577. assert sys.exc_info()[:-1] == foo[:2] # y
  578. assert sys.exc_info()[:-2] == foo[:1] # y
  579. assert sys.exc_info()[:-3] == () # y
  580. test_returns_slice_2.expected = 'nyyynnyyy'
  581. def test_returns_slice_3(self):
  582. import sys
  583. e = KeyError("boom")
  584. try:
  585. raise e
  586. except:
  587. foo = sys.exc_info() # n
  588. assert sys.exc_info()[2:2] == () # y
  589. assert sys.exc_info()[0:1] == foo[:1] # y
  590. assert sys.exc_info()[1:2] == foo[1:2] # y
  591. assert sys.exc_info()[0:3] == foo # n
  592. assert sys.exc_info()[2:4] == foo[2:] # n
  593. assert sys.exc_info()[0:-1] == foo[:2] # y
  594. assert sys.exc_info()[0:-2] == foo[:1] # y
  595. assert sys.exc_info()[5:-3] == () # y
  596. test_returns_slice_3.expected = 'nyyynnyyy'
  597. def test_strange_invocation(self):
  598. import sys
  599. e = KeyError("boom")
  600. try:
  601. raise e
  602. except:
  603. a = []; k = {}
  604. assert sys.exc_info(*a)[:0] == ()
  605. assert sys.exc_info(**k)[:0] == ()
  606. test_strange_invocation.expected = 'nn'
  607. def test_call_in_subfunction(self):
  608. import sys
  609. def g():
  610. # this case is not optimized, because we need to search the
  611. # frame chain. it's probably not worth the complications
  612. return sys.exc_info()[1]
  613. e = KeyError("boom")
  614. try:
  615. raise e
  616. except:
  617. assert g() is e
  618. test_call_in_subfunction.expected = 'n'
  619. class AppTestSysExcInfoDirectCallMethod(AppTestSysExcInfoDirect):
  620. def setup_class(cls):
  621. cls.space = gettestobjspace(**{"objspace.opcodes.CALL_METHOD": True})