code: def test_build_ext(self):
      global ALREADY_TESTED
      support.copy_xxmodule_c(self.tmp_dir)
      self.xx_created = True
      xx_c = os.path.join(self.tmp_dir, "xxmodule.c")
      xx_ext = Extension("xx", [xx_c])
      dist = Distribution({"name": "xx", "ext_modules": [xx_ext]})
      dist.package_dir = self.tmp_dir
      cmd = build_ext(dist)
      support.fixup_build_ext(cmd)
      cmd.build_lib = self.tmp_dir
      cmd.build_temp = self.tmp_dir
  
      old_stdout = sys.stdout
      if not test_support.verbose:
          # silence compiler output
          sys.stdout = StringIO()
      try:
          cmd.ensure_finalized()
          cmd.run()
      finally:
          sys.stdout = old_stdout
  
      if ALREADY_TESTED:
          self.skipTest("Already tested in %s" % ALREADY_TESTED)
      else:
          ALREADY_TESTED = type(self).__name__
  
      import xx
  
      for attr in ("error", "foo", "new", "roj"):
          self.assertTrue(hasattr(xx, attr))
  
      self.assertEqual(xx.foo(2, 5), 7)
      self.assertEqual(xx.foo(13, 15), 28)
      self.assertEqual(xx.new().demo(), None)
      if test_support.HAVE_DOCSTRINGS:
          doc = "This is a template module just for instruction."
          self.assertEqual(xx.__doc__, doc)
      self.assertIsInstance(xx.Null(), xx.Null)
      self.assertIsInstance(xx.Str(), xx.Str)
  
imports: import sys
  import os
  from StringIO import StringIO
  import textwrap
  from distutils.core import Extension, Distribution
  from distutils.command.build_ext import build_ext
  from distutils import sysconfig
  from distutils.tests import support
  from distutils.errors import DistutilsSetupError, CompileError, DistutilsPlatformError
  import unittest
  from test import test_support
label_desc: Use image node_id 3 for calling the BuildExtTestCase obj's underlying member method code with example usage: obj.test_build_ext() without return types