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

Side by Side Diff: Lib/test/test_platform.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 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 | « Lib/test/test_pipes.py ('k') | Lib/test/test_poll.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from unittest import mock 1 from unittest import mock
2 import os 2 import os
3 import platform 3 import platform
4 import subprocess 4 import subprocess
5 import sys 5 import sys
6 import tempfile 6 import tempfile
7 import unittest 7 import unittest
8 import warnings 8 import warnings
9 9
10 from test import support 10 from test import support
11 11
12 class PlatformTest(unittest.TestCase): 12 class PlatformTest(unittest.TestCase):
13 def test_architecture(self): 13 def test_architecture(self):
14 res = platform.architecture() 14 res = platform.architecture()
15 15
16 @support.skip_unless_symlink 16 @support.skip_unless_symlink
17 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
17 def test_architecture_via_symlink(self): # issue3762 18 def test_architecture_via_symlink(self): # issue3762
18 # On Windows, the EXE needs to know where pythonXY.dll is at so we have 19 # On Windows, the EXE needs to know where pythonXY.dll is at so we have
19 # to add the directory to the path. 20 # to add the directory to the path.
20 if sys.platform == "win32": 21 if sys.platform == "win32":
21 os.environ["Path"] = "{};{}".format( 22 os.environ["Path"] = "{};{}".format(
22 os.path.dirname(sys.executable), os.environ["Path"]) 23 os.path.dirname(sys.executable), os.environ["Path"])
23 24
24 def get(python): 25 def get(python):
25 cmd = [python, '-c', 26 cmd = [python, '-c',
26 'import platform; print(platform.architecture())'] 27 'import platform; print(platform.architecture())']
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 res = platform.java_ver() 181 res = platform.java_ver()
181 if sys.platform == 'java': 182 if sys.platform == 'java':
182 self.assertTrue(all(res)) 183 self.assertTrue(all(res))
183 184
184 def test_win32_ver(self): 185 def test_win32_ver(self):
185 res = platform.win32_ver() 186 res = platform.win32_ver()
186 187
187 def test_mac_ver(self): 188 def test_mac_ver(self):
188 res = platform.mac_ver() 189 res = platform.mac_ver()
189 190
190 if platform.uname().system == 'Darwin': 191 if platform.uname().system == 'Darwin' and sys.platform != 'ios':
191 # We're on a MacOSX system, check that 192 # We're on a MacOSX system, check that
192 # the right version information is returned 193 # the right version information is returned
193 fd = os.popen('sw_vers', 'r') 194 fd = os.popen('sw_vers', 'r')
194 real_ver = None 195 real_ver = None
195 for ln in fd: 196 for ln in fd:
196 if ln.startswith('ProductVersion:'): 197 if ln.startswith('ProductVersion:'):
197 real_ver = ln.strip().split()[-1] 198 real_ver = ln.strip().split()[-1]
198 break 199 break
199 fd.close() 200 fd.close()
200 self.assertFalse(real_ver is None) 201 self.assertFalse(real_ver is None)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 ('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux' )), 266 ('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux' )),
266 ('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psy che')), 267 ('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psy che')),
267 ('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike' )), 268 ('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike' )),
268 ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')), 269 ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')),
269 ('CentOS release 4', ('CentOS', '4', None)), 270 ('CentOS release 4', ('CentOS', '4', None)),
270 ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')), 271 ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')),
271 ('', ('', '', '')), # If there's nothing there. 272 ('', ('', '', '')), # If there's nothing there.
272 ): 273 ):
273 self.assertEqual(platform._parse_release_file(input), output) 274 self.assertEqual(platform._parse_release_file(input), output)
274 275
276 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
275 def test_popen(self): 277 def test_popen(self):
276 mswindows = (sys.platform == "win32") 278 mswindows = (sys.platform == "win32")
277 279
278 if mswindows: 280 if mswindows:
279 command = '"{}" -c "print(\'Hello\')"'.format(sys.executable) 281 command = '"{}" -c "print(\'Hello\')"'.format(sys.executable)
280 else: 282 else:
281 command = "'{}' -c 'print(\"Hello\")'".format(sys.executable) 283 command = "'{}' -c 'print(\"Hello\")'".format(sys.executable)
282 with warnings.catch_warnings(): 284 with warnings.catch_warnings():
283 warnings.simplefilter("ignore", DeprecationWarning) 285 warnings.simplefilter("ignore", DeprecationWarning)
284 with platform.popen(command) as stdout: 286 with platform.popen(command) as stdout:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 def test_linux_distribution_deprecation(self): 341 def test_linux_distribution_deprecation(self):
340 with self.assertWarns(PendingDeprecationWarning) as cm: 342 with self.assertWarns(PendingDeprecationWarning) as cm:
341 platform.linux_distribution() 343 platform.linux_distribution()
342 self.assertEqual(str(cm.warning), 344 self.assertEqual(str(cm.warning),
343 'dist() and linux_distribution() functions are ' 345 'dist() and linux_distribution() functions are '
344 'deprecated in Python 3.5 and will be removed in ' 346 'deprecated in Python 3.5 and will be removed in '
345 'Python 3.7') 347 'Python 3.7')
346 348
347 if __name__ == '__main__': 349 if __name__ == '__main__':
348 unittest.main() 350 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_pipes.py ('k') | Lib/test/test_poll.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+