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