33# Copyright (c) 2004, Enthought, Inc.
44
55"""Tests class_tree.py. Uses the vtk module to test the code. Also
6- tests if the tree generation works for the __builtin__ module.
6+ tests if the tree generation works for the builtins module.
77
88"""
9-
9+ import builtins
1010import sys
1111import unittest
1212from contextlib import contextmanager
1313
1414from tvtk import class_tree
1515
1616import vtk
17- if sys .version_info [0 ] > 2 :
18- import builtins as __builtin__
19- PY_VER = 3
20- else :
21- import __builtin__
22- PY_VER = 2
2317
2418# This computation can be expensive, so we cache it.
2519_cache = class_tree .ClassTree (vtk )
@@ -42,14 +36,14 @@ def setUp(self):
4236 @contextmanager
4337 def _remove_loader_from_builtin (self ):
4438 self ._loader = None
45- if hasattr (__builtin__ , '__loader__' ):
46- self ._loader = __builtin__ .__loader__
47- del __builtin__ .__loader__
39+ if hasattr (builtins , '__loader__' ):
40+ self ._loader = builtins .__loader__
41+ del builtins .__loader__
4842 try :
4943 yield
5044 finally :
5145 if self ._loader :
52- __builtin__ .__loader__ = self ._loader
46+ builtins .__loader__ = self ._loader
5347
5448 def test_basic_vtk (self ):
5549 """Basic tests for the VTK module."""
@@ -76,16 +70,11 @@ def test_basic_vtk(self):
7670 expect = ['object' , 'vtkColor3' , 'vtkColor4' , 'vtkDenseArray' ,
7771 'vtkQuaternion' , 'vtkRect' ,
7872 'vtkSparseArray' , 'vtkTuple' ,
79- 'vtkTypedArray' , 'vtkVariantStrictWeakOrderKey' ,
80- 'vtkVector' , 'vtkVector2' , 'vtkVector3' ]
81- if PY_VER == 3 :
82- expect .remove ('vtkVariantStrictWeakOrderKey' )
73+ 'vtkTypedArray' ,'vtkVector' ,
74+ 'vtkVector2' , 'vtkVector3' ]
8375 else :
8476 self .assertGreaterEqual (vtk_major_version , 8 )
85- if PY_VER == 3 :
86- expect = ['object' ]
87- else :
88- expect = ['object' , 'vtkVariantStrictWeakOrderKey' ]
77+ expect = ['object' ]
8978 self .assertEqual (names , expect )
9079 elif (hasattr (vtk , 'vtkVector' )):
9180 self .assertEqual (len (t .tree [0 ]), 11 )
@@ -133,9 +122,9 @@ def _get_ancestors(klass):
133122 bases .extend (_get_ancestors (base ))
134123 return bases
135124
136- # Simple __builtin__ test.
125+ # Simple builtins test.
137126 with self ._remove_loader_from_builtin ():
138- t = class_tree .ClassTree (__builtin__ )
127+ t = class_tree .ClassTree (builtins )
139128 t .create ()
140129 n = t .get_node ('TabError' )
141130 bases = [x .__name__ for x in _get_ancestors (TabError )]
@@ -176,12 +165,12 @@ def test_tree(self):
176165 self .assertEqual (n .level , level )
177166
178167 def test_builtin (self ):
179- """Check if tree structure for __builtin__ works."""
168+ """Check if tree structure for builtins works."""
180169
181170 # This tests to see if the tree structure generation works for
182- # the __builtin__ module.
171+ # the builtins module.
183172 with self ._remove_loader_from_builtin ():
184- t = class_tree .ClassTree (__builtin__ )
173+ t = class_tree .ClassTree (builtins )
185174 t .create ()
186175 self .t = t
187176 self .test_parent_child ()
0 commit comments