MCPcopy Index your code
hub / github.com/python/cpython / test_get_platform

Method test_get_platform

Lib/test/test_sysconfig.py:245–386  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

243 self.assertTrue(cvars)
244
245 def test_get_platform(self):
246 # Check the actual platform returns something reasonable.
247 actual_platform = get_platform()
248 self.assertIsInstance(actual_platform, str)
249 self.assertTrue(actual_platform)
250
251 # Windows
252 os.name = 'nt'
253 with patch('_sysconfig.get_platform', create=True, return_value='win32'):
254 self.assertEqual(get_platform(), 'win32')
255 with patch('_sysconfig.get_platform', create=True, return_value='win-amd64'):
256 self.assertEqual(get_platform(), 'win-amd64')
257 sys.platform = 'test-plaform'
258 with patch('_sysconfig.get_platform', create=True, return_value=None):
259 self.assertEqual(get_platform(), 'test-plaform')
260
261 # macbook
262 os.name = 'posix'
263 sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
264 '\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
265 sys.platform = 'darwin'
266 self._set_uname(('Darwin', 'macziade', '8.11.1',
267 ('Darwin Kernel Version 8.11.1: '
268 'Wed Oct 10 18:23:28 PDT 2007; '
269 'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC'))
270 _osx_support._remove_original_values(get_config_vars())
271 get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
272
273 get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
274 '-fwrapv -O3 -Wall -Wstrict-prototypes')
275
276 maxint = sys.maxsize
277 try:
278 sys.maxsize = 2147483647
279 self.assertEqual(get_platform(), 'macosx-10.3-ppc')
280 sys.maxsize = 9223372036854775807
281 self.assertEqual(get_platform(), 'macosx-10.3-ppc64')
282 finally:
283 sys.maxsize = maxint
284
285 self._set_uname(('Darwin', 'macziade', '8.11.1',
286 ('Darwin Kernel Version 8.11.1: '
287 'Wed Oct 10 18:23:28 PDT 2007; '
288 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
289 _osx_support._remove_original_values(get_config_vars())
290 get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
291
292 get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
293 '-fwrapv -O3 -Wall -Wstrict-prototypes')
294 maxint = sys.maxsize
295 try:
296 sys.maxsize = 2147483647
297 self.assertEqual(get_platform(), 'macosx-10.3-i386')
298 sys.maxsize = 9223372036854775807
299 self.assertEqual(get_platform(), 'macosx-10.3-x86_64')
300 finally:
301 sys.maxsize = maxint
302

Callers

nothing calls this directly

Calls 9

_set_unameMethod · 0.95
get_platformFunction · 0.90
patchFunction · 0.90
get_config_varsFunction · 0.90
assertIsInstanceMethod · 0.80
assertTrueMethod · 0.80
assertEqualMethod · 0.45
itemsMethod · 0.45
subTestMethod · 0.45

Tested by

no test coverage detected