| OLD | NEW |
| 1 """Tests for packaging.command.install_data.""" | 1 """Tests for packaging.command.install_data.""" |
| 2 import os | 2 import os |
| 3 import sys | 3 import sys |
| 4 import sysconfig | 4 import sysconfig |
| 5 import packaging.database | 5 import packaging.database |
| 6 from sysconfig import _get_default_scheme | 6 from sysconfig import _get_default_scheme |
| 7 from packaging.tests import unittest, support | 7 from packaging.tests import unittest, support |
| 8 from packaging.command.install_data import install_data | 8 from packaging.command.install_data import install_data |
| 9 from packaging.command.install_dist import install_dist | 9 from packaging.command.install_dist import install_dist |
| 10 from packaging.command.install_distinfo import install_distinfo | 10 from packaging.command.install_distinfo import install_distinfo |
| 11 | 11 |
| 12 | 12 |
| 13 class InstallDataTestCase(support.TempdirManager, | 13 class InstallDataTestCase(support.TempdirManager, |
| 14 support.LoggingCatcher, | 14 support.LoggingCatcher, |
| 15 unittest.TestCase): | 15 unittest.TestCase): |
| 16 | 16 |
| 17 def setUp(self): | 17 def setUp(self): |
| 18 super(InstallDataTestCase, self).setUp() | 18 super(InstallDataTestCase, self).setUp() |
| 19 scheme = _get_default_scheme() | 19 scheme = _get_default_scheme() |
| 20 old_items = sysconfig._SCHEMES.items(scheme) | 20 old_sections = sysconfig._SCHEMES._sections.copy() |
| 21 | 21 |
| 22 def restore(): | 22 def restore(): |
| 23 sysconfig._SCHEMES.remove_section(scheme) | 23 sysconfig._SCHEMES._sections.clear() |
| 24 sysconfig._SCHEMES.add_section(scheme) | 24 sysconfig._SCHEMES._sections.update(old_sections) |
| 25 for option, value in old_items: | |
| 26 sysconfig._SCHEMES.set(scheme, option, value) | |
| 27 | 25 |
| 28 self.addCleanup(restore) | 26 self.addCleanup(restore) |
| 29 | 27 |
| 30 def test_simple_run(self): | 28 def test_simple_run(self): |
| 31 pkg_dir, dist = self.create_dist() | 29 pkg_dir, dist = self.create_dist() |
| 32 cmd = install_data(dist) | 30 cmd = install_data(dist) |
| 33 cmd.install_dir = inst = os.path.join(pkg_dir, 'inst') | 31 cmd.install_dir = inst = os.path.join(pkg_dir, 'inst') |
| 34 scheme = _get_default_scheme() | 32 scheme = _get_default_scheme() |
| 35 | 33 |
| 36 sysconfig._SCHEMES.set(scheme, 'inst', | 34 sysconfig._SCHEMES.set(scheme, 'inst', |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 content = fp.read() | 137 content = fp.read() |
| 140 | 138 |
| 141 self.assertEqual('# Python script', content) | 139 self.assertEqual('# Python script', content) |
| 142 | 140 |
| 143 | 141 |
| 144 def test_suite(): | 142 def test_suite(): |
| 145 return unittest.makeSuite(InstallDataTestCase) | 143 return unittest.makeSuite(InstallDataTestCase) |
| 146 | 144 |
| 147 if __name__ == "__main__": | 145 if __name__ == "__main__": |
| 148 unittest.main(defaultTest="test_suite") | 146 unittest.main(defaultTest="test_suite") |
| OLD | NEW |