Lines Matching full:sys
9 import sys
18 savestdout = sys.stdout
20 sys.stdout = out
22 dh = sys.__displayhook__
35 del sys.stdout
38 sys.stdout = savestdout
41 olddisplayhook = sys.displayhook
42 del sys.displayhook
45 sys.displayhook = olddisplayhook
48 olddisplayhook = sys.displayhook
51 sys.displayhook = baddisplayhook
54 sys.displayhook = olddisplayhook
57 savestderr = sys.stderr
59 sys.stderr = err
61 eh = sys.__excepthook__
67 eh(*sys.exc_info())
69 sys.stderr = savestderr
76 self.assertRaises(TypeError, sys.exc_clear, 42)
81 typ, value, traceback = sys.exc_info()
87 sys.exc_clear()
89 typ, value, traceback = sys.exc_info()
108 typ1, value1, traceback1 = sys.exc_info()
110 typ2, value2, traceback2 = sys.exc_info()
122 self.assertRaises(TypeError, sys.exit, 42, 42)
126 sys.exit()
129 rc, out, err = assert_python_ok('-c', 'import sys; sys.exit()')
136 sys.exit(42)
142 sys.exit((42,))
147 sys.exit("exit")
152 sys.exit((17, 23))
188 r'import sys; sys.stderr.write("unflushed,"); sys.exit("message")',
193 r'import sys; sys.exit(u"h\xe9")',
198 self.assertRaises(TypeError, sys.getdefaultencoding, 42)
200 self.assertIsInstance(sys.getdefaultencoding(), str)
202 # testing sys.settrace() is done in test_sys_settrace.py
203 # testing sys.setprofile() is done in test_sys_setprofile.py
206 self.assertRaises(TypeError, sys.setcheckinterval)
207 orig = sys.getcheckinterval()
209 sys.setcheckinterval(n)
210 self.assertEqual(sys.getcheckinterval(), n)
213 self.assertRaises(TypeError, sys.getrecursionlimit, 42)
214 oldlimit = sys.getrecursionlimit()
215 self.assertRaises(TypeError, sys.setrecursionlimit)
216 self.assertRaises(ValueError, sys.setrecursionlimit, -42)
217 sys.setrecursionlimit(10000)
218 self.assertEqual(sys.getrecursionlimit(), 10000)
219 sys.setrecursionlimit(oldlimit)
221 self.assertRaises(OverflowError, sys.setrecursionlimit, 1 << 31)
223 sys.setrecursionlimit((1 << 31) - 5)
231 sys.setrecursionlimit(oldlimit)
234 # Raise SkipTest if sys doesn't have getwindowsversion attribute
235 test.test_support.get_attribute(sys, "getwindowsversion")
236 v = sys.getwindowsversion()
261 maj, min, buildno, plat, csd = sys.getwindowsversion()
263 @unittest.skipUnless(hasattr(sys, "setdlopenflags"),
264 'test needs sys.setdlopenflags()')
266 self.assertTrue(hasattr(sys, "getdlopenflags"))
267 self.assertRaises(TypeError, sys.getdlopenflags, 42)
268 oldflags = sys.getdlopenflags()
269 self.assertRaises(TypeError, sys.setdlopenflags)
270 sys.setdlopenflags(oldflags+1)
271 self.assertEqual(sys.getdlopenflags(), oldflags+1)
272 sys.setdlopenflags(oldflags)
280 self.assertRaises(TypeError, sys.getrefcount)
281 c = sys.getrefcount(None)
283 self.assertEqual(sys.getrefcount(None), c+1)
285 self.assertEqual(sys.getrefcount(None), c)
286 if hasattr(sys, "gettotalrefcount"):
287 self.assertIsInstance(sys.gettotalrefcount(), int)
290 self.assertRaises(TypeError, sys._getframe, 42, 42)
291 self.assertRaises(ValueError, sys._getframe, 2000000000)
294 is sys._getframe().f_code
297 # sys._current_frames() is a CPython-only gimmick.
310 # Test sys._current_frames() in a WITH_THREADS build.
317 # thread does sys._current_frames(), and verifies that the frames
341 d = sys._current_frames()
349 self.assertTrue(frame is sys._getframe())
373 # Test sys._current_frames() when thread support doesn't exist.
377 d = sys._current_frames()
380 self.assertTrue(d[0] is sys._getframe())
383 self.assertIsInstance(sys.api_version, int)
384 self.assertIsInstance(sys.argv, list)
385 self.assertIn(sys.byteorder, ("little", "big"))
386 self.assertIsInstance(sys.builtin_module_names, tuple)
387 self.assertIsInstance(sys.copyright, basestring)
388 self.assertIsInstance(sys.exec_prefix, basestring)
389 self.assertIsInstance(sys.executable, basestring)
390 self.assertEqual(len(sys.float_info), 11)
391 self.assertEqual(sys.float_info.radix, 2)
392 self.assertEqual(len(sys.long_info), 2)
393 self.assertTrue(sys.long_info.bits_per_digit % 5 == 0)
394 self.assertTrue(sys.long_info.sizeof_digit >= 1)
395 self.assertEqual(type(sys.long_info.bits_per_digit), int)
396 self.assertEqual(type(sys.long_info.sizeof_digit), int)
397 self.assertIsInstance(sys.hexversion, int)
398 self.assertIsInstance(sys.maxint, int)
400 self.assertIsInstance(sys.maxunicode, int)
401 self.assertIsInstance(sys.platform, basestring)
402 self.assertIsInstance(sys.prefix, basestring)
403 self.assertIsInstance(sys.version, basestring)
404 vi = sys.version_info
423 self.assertIsInstance(sys.float_repr_style, str)
424 self.assertIn(sys.float_repr_style, ('short', 'legacy'))
427 # Can't use sys.stdout, as this is a cStringIO object when
430 (sys.__stdout__.isatty() and sys.__stderr__.isatty())):
432 self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)
435 self.assertTrue(sys.flags)
441 self.assertTrue(hasattr(sys.flags, attr), attr)
442 self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
443 self.assertTrue(repr(sys.flags))
447 sys._clear_type_cache()
457 p = subprocess.Popen([sys.executable, "-c", 'print unichr(0xa2)'],
463 p = subprocess.Popen([sys.executable, "-c", 'print unichr(0xa2)'],
469 self.assertEqual(sys.call_tracing(str, (2,)), "2")
470 self.assertRaises(TypeError, sys.call_tracing, str, 2)
473 # sys.executable should be absolute
474 self.assertEqual(os.path.abspath(sys.executable), sys.executable)
476 # Issue #7774: Ensure that sys.executable is an empty string if argv[0]
482 python_dir = os.path.dirname(os.path.realpath(sys.executable))
484 ["nonexistent", "-c", 'import sys; print repr(sys.executable)'],
485 executable=sys.executable, stdout=subprocess.PIPE, cwd=python_dir)
488 self.assertIn(executable, ["''", repr(sys.executable)])
495 self.longdigit = sys.long_info.sizeof_digit
506 self.assertEqual(sys.getsizeof(True), size('l'))
508 self.assertEqual(sys.getsizeof([]), size('P PP') + gc_header_size)
514 self.assertRaises(ValueError, sys.getsizeof, BadSizeof())
519 self.assertRaises(TypeError, sys.getsizeof, InvalidSizeof())
521 self.assertIs(sys.getsizeof(InvalidSizeof(), sentinel), sentinel)
526 self.assertEqual(sys.getsizeof(OverflowSizeof(sys.maxsize)),
527 sys.maxsize + self.gc_headsize)
529 sys.getsizeof(OverflowSizeof(sys.maxsize + 1))
531 sys.getsizeof(OverflowSizeof(-1))
533 sys.getsizeof(OverflowSizeof(-sys.maxsize - 1))
537 self.assertEqual(sys.getsizeof(True, -1), size('l'))
639 # sys.floatinfo
640 check(sys.float_info, vsize('') + self.P * len(sys.float_info))
691 PyLong_BASE = 2**sys.long_info.bits_per_digit
752 if hasattr(sys, 'getcounts'):
787 expected = sys.getsizeof(base) + struct.calcsize(extra)
790 self.assertEqual(sys.getsizeof(obj), expected)
831 tb = sys.exc_info()[2]
837 # sys.flags
838 check(sys.flags, vsize('') + self.P * len(sys.flags))