test_install_headers.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """Tests for distutils.command.install_headers."""
  2. import os
  3. import unittest
  4. from distutils.command.install_headers import install_headers
  5. from distutils.tests import support
  6. from test.support import run_unittest
  7. class InstallHeadersTestCase(support.TempdirManager,
  8. support.LoggingSilencer,
  9. support.EnvironGuard,
  10. unittest.TestCase):
  11. def test_simple_run(self):
  12. # we have two headers
  13. header_list = self.mkdtemp()
  14. header1 = os.path.join(header_list, 'header1')
  15. header2 = os.path.join(header_list, 'header2')
  16. self.write_file(header1)
  17. self.write_file(header2)
  18. headers = [header1, header2]
  19. pkg_dir, dist = self.create_dist(headers=headers)
  20. cmd = install_headers(dist)
  21. self.assertEqual(cmd.get_inputs(), headers)
  22. # let's run the command
  23. cmd.install_dir = os.path.join(pkg_dir, 'inst')
  24. cmd.ensure_finalized()
  25. cmd.run()
  26. # let's check the results
  27. self.assertEqual(len(cmd.get_outputs()), 2)
  28. def test_suite():
  29. return unittest.makeSuite(InstallHeadersTestCase)
  30. if __name__ == "__main__":
  31. run_unittest(test_suite())