site.USER_BASE = self.mkdtemp()
build_ext.USER_BASE = site.USER_BASE
- unload('xx')
- sys.path.remove(self.tmp_dir)
+ def tearDown(self):
+ # Get everything back to normal
+ if sys.version > "2.6":
+ site.USER_BASE = self.old_user_base
+ build_ext.USER_BASE = self.old_user_base
+
+ super(BuildExtTestCase, self).tearDown()
+
def _fixup_command(self, cmd):
# When Python was build with --enable-shared, -L. is not good enough
# to find the libpython<blah>.so. This is because regrtest runs it
finally:
sys.stdout = old_stdout
- if ALREADY_TESTED:
- return
- else:
- ALREADY_TESTED = True
+ code = """if 1:
+ import sys
+ sys.path.insert(0, %r)
- import xx
+ import xx
- for attr in ('error', 'foo', 'new', 'roj'):
- self.assertTrue(hasattr(xx, attr))
+ for attr in ('error', 'foo', 'new', 'roj'):
+ assert hasattr(xx, attr)
- self.assertEqual(xx.foo(2, 5), 7)
- self.assertEqual(xx.foo(13, 15), 28)
- self.assertEqual(xx.new().demo(), None)
- doc = 'This is a template module just for instruction.'
- self.assertEqual(xx.__doc__, doc)
- self.assertTrue(isinstance(xx.Null(), xx.Null))
- self.assertTrue(isinstance(xx.Str(), xx.Str))
+ assert xx.foo(2, 5) == 7
+ assert xx.foo(13, 15) == 28
+ assert xx.new().demo() is None
+ doc = 'This is a template module just for instruction.'
+ assert xx.__doc__ == doc
+ assert isinstance(xx.Null(), xx.Null)
+ assert isinstance(xx.Str(), xx.Str)"""
+ code = code % self.tmp_dir
+ assert_python_ok('-c', code)
- def tearDown(self):
- # Get everything back to normal
- if sys.version > "2.6":
- site.USER_BASE = self.old_user_base
- build_ext.USER_BASE = self.old_user_base
-
- super(BuildExtTestCase, self).tearDown()
-
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)