Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1636)

Side by Side Diff: Lib/packaging/tests/test_command_install_data.py

Issue 14057: Speedup sysconfig startup
Patch Set: Created 1 year, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/sysconfig.py » ('j') | Lib/sysconfig.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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")
OLDNEW
« no previous file with comments | « no previous file | Lib/sysconfig.py » ('j') | Lib/sysconfig.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7