summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py102
1 files changed, 51 insertions, 51 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 8f68cf7..cac90f4 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -30,7 +30,7 @@ class SysModuleTest(unittest.TestCase):
dh(None)
self.assertEqual(out.getvalue(), "")
- self.assert_(not hasattr(builtins, "_"))
+ self.assertTrue(not hasattr(builtins, "_"))
dh(42)
self.assertEqual(out.getvalue(), "42\n")
self.assertEqual(builtins._, 42)
@@ -62,12 +62,12 @@ class SysModuleTest(unittest.TestCase):
except ValueError as exc:
eh(*sys.exc_info())
- self.assert_(err.getvalue().endswith("ValueError: 42\n"))
+ self.assertTrue(err.getvalue().endswith("ValueError: 42\n"))
def test_excepthook(self):
with test.support.captured_output("stderr") as stderr:
sys.excepthook(1, '1', 1)
- self.assert_("TypeError: print_exception(): Exception expected for " \
+ self.assertTrue("TypeError: print_exception(): Exception expected for " \
"value, str found" in stderr.getvalue())
# FIXME: testing the code for a lost or replaced excepthook in
@@ -136,7 +136,7 @@ class SysModuleTest(unittest.TestCase):
def test_getdefaultencoding(self):
self.assertRaises(TypeError, sys.getdefaultencoding, 42)
# can't check more than the type, as the user might have changed it
- self.assert_(isinstance(sys.getdefaultencoding(), str))
+ self.assertTrue(isinstance(sys.getdefaultencoding(), str))
# testing sys.settrace() is done in test_trace.py
# testing sys.setprofile() is done in test_profile.py
@@ -203,20 +203,20 @@ class SysModuleTest(unittest.TestCase):
def test_getwindowsversion(self):
if hasattr(sys, "getwindowsversion"):
v = sys.getwindowsversion()
- self.assert_(isinstance(v, tuple))
+ self.assertTrue(isinstance(v, tuple))
self.assertEqual(len(v), 5)
- self.assert_(isinstance(v[0], int))
- self.assert_(isinstance(v[1], int))
- self.assert_(isinstance(v[2], int))
- self.assert_(isinstance(v[3], int))
- self.assert_(isinstance(v[4], str))
+ self.assertTrue(isinstance(v[0], int))
+ self.assertTrue(isinstance(v[1], int))
+ self.assertTrue(isinstance(v[2], int))
+ self.assertTrue(isinstance(v[3], int))
+ self.assertTrue(isinstance(v[4], str))
def test_call_tracing(self):
self.assertRaises(TypeError, sys.call_tracing, type, 2)
def test_dlopenflags(self):
if hasattr(sys, "setdlopenflags"):
- self.assert_(hasattr(sys, "getdlopenflags"))
+ self.assertTrue(hasattr(sys, "getdlopenflags"))
self.assertRaises(TypeError, sys.getdlopenflags, 42)
oldflags = sys.getdlopenflags()
self.assertRaises(TypeError, sys.setdlopenflags)
@@ -237,12 +237,12 @@ class SysModuleTest(unittest.TestCase):
del n
self.assertEqual(sys.getrefcount(None), c)
if hasattr(sys, "gettotalrefcount"):
- self.assert_(isinstance(sys.gettotalrefcount(), int))
+ self.assertTrue(isinstance(sys.gettotalrefcount(), int))
def test_getframe(self):
self.assertRaises(TypeError, sys._getframe, 42, 42)
self.assertRaises(ValueError, sys._getframe, 2000000000)
- self.assert_(
+ self.assertTrue(
SysModuleTest.test_getframe.__code__ \
is sys._getframe().f_code
)
@@ -293,12 +293,12 @@ class SysModuleTest(unittest.TestCase):
d = sys._current_frames()
main_id = _thread.get_ident()
- self.assert_(main_id in d)
- self.assert_(thread_id in d)
+ self.assertTrue(main_id in d)
+ self.assertTrue(thread_id in d)
# Verify that the captured main-thread frame is _this_ frame.
frame = d.pop(main_id)
- self.assert_(frame is sys._getframe())
+ self.assertTrue(frame is sys._getframe())
# Verify that the captured thread frame is blocked in g456, called
# from f123. This is a litte tricky, since various bits of
@@ -316,7 +316,7 @@ class SysModuleTest(unittest.TestCase):
# And the next record must be for g456().
filename, lineno, funcname, sourceline = stack[i+1]
self.assertEqual(funcname, "g456")
- self.assert_(sourceline in ["leave_g.wait()", "entered_g.set()"])
+ self.assertTrue(sourceline in ["leave_g.wait()", "entered_g.set()"])
# Reap the spawned thread.
leave_g.set()
@@ -328,50 +328,50 @@ class SysModuleTest(unittest.TestCase):
# "thread id" 0.
d = sys._current_frames()
self.assertEqual(len(d), 1)
- self.assert_(0 in d)
- self.assert_(d[0] is sys._getframe())
+ self.assertTrue(0 in d)
+ self.assertTrue(d[0] is sys._getframe())
def test_attributes(self):
- self.assert_(isinstance(sys.api_version, int))
- self.assert_(isinstance(sys.argv, list))
- self.assert_(sys.byteorder in ("little", "big"))
- self.assert_(isinstance(sys.builtin_module_names, tuple))
- self.assert_(isinstance(sys.copyright, str))
- self.assert_(isinstance(sys.exec_prefix, str))
- self.assert_(isinstance(sys.executable, str))
+ self.assertTrue(isinstance(sys.api_version, int))
+ self.assertTrue(isinstance(sys.argv, list))
+ self.assertTrue(sys.byteorder in ("little", "big"))
+ self.assertTrue(isinstance(sys.builtin_module_names, tuple))
+ self.assertTrue(isinstance(sys.copyright, str))
+ self.assertTrue(isinstance(sys.exec_prefix, str))
+ self.assertTrue(isinstance(sys.executable, str))
self.assertEqual(len(sys.float_info), 11)
self.assertEqual(sys.float_info.radix, 2)
self.assertEqual(len(sys.int_info), 2)
- self.assert_(sys.int_info.bits_per_digit % 5 == 0)
- self.assert_(sys.int_info.sizeof_digit >= 1)
+ self.assertTrue(sys.int_info.bits_per_digit % 5 == 0)
+ self.assertTrue(sys.int_info.sizeof_digit >= 1)
self.assertEqual(type(sys.int_info.bits_per_digit), int)
self.assertEqual(type(sys.int_info.sizeof_digit), int)
- self.assert_(isinstance(sys.hexversion, int))
- self.assert_(isinstance(sys.maxsize, int))
- self.assert_(isinstance(sys.maxunicode, int))
- self.assert_(isinstance(sys.platform, str))
- self.assert_(isinstance(sys.prefix, str))
- self.assert_(isinstance(sys.version, str))
+ self.assertTrue(isinstance(sys.hexversion, int))
+ self.assertTrue(isinstance(sys.maxsize, int))
+ self.assertTrue(isinstance(sys.maxunicode, int))
+ self.assertTrue(isinstance(sys.platform, str))
+ self.assertTrue(isinstance(sys.prefix, str))
+ self.assertTrue(isinstance(sys.version, str))
vi = sys.version_info
- self.assert_(isinstance(vi[:], tuple))
+ self.assertTrue(isinstance(vi[:], tuple))
self.assertEqual(len(vi), 5)
- self.assert_(isinstance(vi[0], int))
- self.assert_(isinstance(vi[1], int))
- self.assert_(isinstance(vi[2], int))
- self.assert_(vi[3] in ("alpha", "beta", "candidate", "final"))
- self.assert_(isinstance(vi[4], int))
- self.assert_(isinstance(vi.major, int))
- self.assert_(isinstance(vi.minor, int))
- self.assert_(isinstance(vi.micro, int))
- self.assert_(vi.releaselevel in
+ self.assertTrue(isinstance(vi[0], int))
+ self.assertTrue(isinstance(vi[1], int))
+ self.assertTrue(isinstance(vi[2], int))
+ self.assertTrue(vi[3] in ("alpha", "beta", "candidate", "final"))
+ self.assertTrue(isinstance(vi[4], int))
+ self.assertTrue(isinstance(vi.major, int))
+ self.assertTrue(isinstance(vi.minor, int))
+ self.assertTrue(isinstance(vi.micro, int))
+ self.assertTrue(vi.releaselevel in
("alpha", "beta", "candidate", "final"))
- self.assert_(isinstance(vi.serial, int))
+ self.assertTrue(isinstance(vi.serial, int))
self.assertEqual(vi[0], vi.major)
self.assertEqual(vi[1], vi.minor)
self.assertEqual(vi[2], vi.micro)
self.assertEqual(vi[3], vi.releaselevel)
self.assertEqual(vi[4], vi.serial)
- self.assert_(vi > (1,0,0))
+ self.assertTrue(vi > (1,0,0))
def test_43581(self):
# Can't use sys.stdout, as this is a StringIO object when
@@ -381,9 +381,9 @@ class SysModuleTest(unittest.TestCase):
def test_intern(self):
self.assertRaises(TypeError, sys.intern)
s = "never interned before"
- self.assert_(sys.intern(s) is s)
+ self.assertTrue(sys.intern(s) is s)
s2 = s.swapcase().swapcase()
- self.assert_(sys.intern(s2) is s)
+ self.assertTrue(sys.intern(s2) is s)
# Subclasses of string can't be interned, because they
# provide too much opportunity for insane things to happen.
@@ -398,15 +398,15 @@ class SysModuleTest(unittest.TestCase):
def test_sys_flags(self):
- self.failUnless(sys.flags)
+ self.assertTrue(sys.flags)
attrs = ("debug", "division_warning",
"inspect", "interactive", "optimize", "dont_write_bytecode",
"no_user_site", "no_site", "ignore_environment", "verbose",
"bytes_warning")
for attr in attrs:
- self.assert_(hasattr(sys.flags, attr), attr)
+ self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
- self.assert_(repr(sys.flags))
+ self.assertTrue(repr(sys.flags))
self.assertEqual(len(sys.flags), len(attrs))
def test_clear_type_cache(self):