summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/pydocfodder.py6
-rwxr-xr-xLib/test/test_grp.py3
-rw-r--r--Lib/test/test_mmap.py7
-rw-r--r--Lib/test/test_pwd.py3
-rw-r--r--Lib/test/test_structmembers.py55
-rw-r--r--Lib/test/test_threading.py18
6 files changed, 68 insertions, 24 deletions
diff --git a/Lib/test/pydocfodder.py b/Lib/test/pydocfodder.py
index 0ae013b..2530320 100644
--- a/Lib/test/pydocfodder.py
+++ b/Lib/test/pydocfodder.py
@@ -1,5 +1,7 @@
"""Something just to look at via pydoc."""
+import types
+
class A_classic:
"A classic class."
def A_method(self):
@@ -208,3 +210,7 @@ class FunkyProperties(object):
del inst.desc[self.attr]
x = property(get_desc('x'), set_desc('x'), del_desc('x'), 'prop x')
+
+
+submodule = types.ModuleType(__name__ + '.submodule',
+ """A submodule, which should appear in its parent's summary""")
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index 24b3f00..fb607f0 100755
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -25,6 +25,9 @@ class GroupDatabaseTestCase(unittest.TestCase):
for e in entries:
self.check_value(e)
+ if len(entries) > 1000: # Huge group file (NIS?) -- skip the rest
+ return
+
for e in entries:
e2 = grp.getgrgid(e.gr_gid)
self.check_value(e2)
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 5bf7eb0..f6ee371 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -419,6 +419,13 @@ class MmapTests(unittest.TestCase):
except OSError:
pass
+ def test_subclass(self):
+ class anon_mmap(mmap.mmap):
+ def __new__(klass, *args, **kwargs):
+ return mmap.mmap.__new__(klass, -1, *args, **kwargs)
+ anon_mmap(PAGESIZE)
+
+
def test_main():
run_unittest(MmapTests)
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index 358b8b3..19187a3 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -35,6 +35,9 @@ class PwdTest(unittest.TestCase):
entriesbyname.setdefault(e.pw_name, []).append(e)
entriesbyuid.setdefault(e.pw_uid, []).append(e)
+ if len(entries) > 1000: # Huge passwd file (NIS?) -- skip the rest
+ return
+
# check whether the entry returned by getpwuid()
# for each uid is among those from getpwall() for this uid
for e in entries:
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py
index 93d7bfb..27b4b70 100644
--- a/Lib/test/test_structmembers.py
+++ b/Lib/test/test_structmembers.py
@@ -8,52 +8,59 @@ from _testcapi import test_structmembersType, \
import warnings, unittest, sys
from test import test_support
-ts=test_structmembersType(1,2,3,4,5,6,7,8,9.99999,10.1010101010)
+ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
+ 9.99999, 10.1010101010)
class ReadWriteTests(unittest.TestCase):
def test_types(self):
- ts.T_BYTE=CHAR_MAX
+ ts.T_BOOL = True
+ self.assertEquals(ts.T_BOOL, True)
+ ts.T_BOOL = False
+ self.assertEquals(ts.T_BOOL, False)
+ self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)
+
+ ts.T_BYTE = CHAR_MAX
self.assertEquals(ts.T_BYTE, CHAR_MAX)
- ts.T_BYTE=CHAR_MIN
+ ts.T_BYTE = CHAR_MIN
self.assertEquals(ts.T_BYTE, CHAR_MIN)
- ts.T_UBYTE=UCHAR_MAX
+ ts.T_UBYTE = UCHAR_MAX
self.assertEquals(ts.T_UBYTE, UCHAR_MAX)
- ts.T_SHORT=SHRT_MAX
+ ts.T_SHORT = SHRT_MAX
self.assertEquals(ts.T_SHORT, SHRT_MAX)
- ts.T_SHORT=SHRT_MIN
+ ts.T_SHORT = SHRT_MIN
self.assertEquals(ts.T_SHORT, SHRT_MIN)
- ts.T_USHORT=USHRT_MAX
+ ts.T_USHORT = USHRT_MAX
self.assertEquals(ts.T_USHORT, USHRT_MAX)
- ts.T_INT=INT_MAX
+ ts.T_INT = INT_MAX
self.assertEquals(ts.T_INT, INT_MAX)
- ts.T_INT=INT_MIN
+ ts.T_INT = INT_MIN
self.assertEquals(ts.T_INT, INT_MIN)
- ts.T_UINT=UINT_MAX
+ ts.T_UINT = UINT_MAX
self.assertEquals(ts.T_UINT, UINT_MAX)
- ts.T_LONG=LONG_MAX
+ ts.T_LONG = LONG_MAX
self.assertEquals(ts.T_LONG, LONG_MAX)
- ts.T_LONG=LONG_MIN
+ ts.T_LONG = LONG_MIN
self.assertEquals(ts.T_LONG, LONG_MIN)
- ts.T_ULONG=ULONG_MAX
+ ts.T_ULONG = ULONG_MAX
self.assertEquals(ts.T_ULONG, ULONG_MAX)
## T_LONGLONG and T_ULONGLONG may not be present on some platforms
if hasattr(ts, 'T_LONGLONG'):
- ts.T_LONGLONG=LLONG_MAX
+ ts.T_LONGLONG = LLONG_MAX
self.assertEquals(ts.T_LONGLONG, LLONG_MAX)
- ts.T_LONGLONG=LLONG_MIN
+ ts.T_LONGLONG = LLONG_MIN
self.assertEquals(ts.T_LONGLONG, LLONG_MIN)
- ts.T_ULONGLONG=ULLONG_MAX
+ ts.T_ULONGLONG = ULLONG_MAX
self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX)
## make sure these will accept a plain int as well as a long
- ts.T_LONGLONG=3
+ ts.T_LONGLONG = 3
self.assertEquals(ts.T_LONGLONG, 3)
- ts.T_ULONGLONG=4
+ ts.T_ULONGLONG = 4
self.assertEquals(ts.T_ULONGLONG, 4)
@@ -63,32 +70,32 @@ class TestWarnings(unittest.TestCase):
def test_byte_max(self):
with test_support.catch_warning() as w:
- ts.T_BYTE=CHAR_MAX+1
+ ts.T_BYTE = CHAR_MAX+1
self.has_warned(w)
def test_byte_min(self):
with test_support.catch_warning() as w:
- ts.T_BYTE=CHAR_MIN-1
+ ts.T_BYTE = CHAR_MIN-1
self.has_warned(w)
def test_ubyte_max(self):
with test_support.catch_warning() as w:
- ts.T_UBYTE=UCHAR_MAX+1
+ ts.T_UBYTE = UCHAR_MAX+1
self.has_warned(w)
def test_short_max(self):
with test_support.catch_warning() as w:
- ts.T_SHORT=SHRT_MAX+1
+ ts.T_SHORT = SHRT_MAX+1
self.has_warned(w)
def test_short_min(self):
with test_support.catch_warning() as w:
- ts.T_SHORT=SHRT_MIN-1
+ ts.T_SHORT = SHRT_MIN-1
self.has_warned(w)
def test_ushort_max(self):
with test_support.catch_warning() as w:
- ts.T_USHORT=USHRT_MAX+1
+ ts.T_USHORT = USHRT_MAX+1
self.has_warned(w)
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 5dd3aea..1ce5950 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -236,6 +236,24 @@ class ThreadTests(unittest.TestCase):
"""])
self.assertEqual(rc, 42)
+ def test_enumerate_after_join(self):
+ # Try hard to trigger #1703448: a thread is still returned in
+ # threading.enumerate() after it has been join()ed.
+ enum = threading.enumerate
+ old_interval = sys.getcheckinterval()
+ sys.setcheckinterval(1)
+ try:
+ for i in range(1, 1000):
+ t = threading.Thread(target=lambda: None)
+ t.start()
+ t.join()
+ l = enum()
+ self.assertFalse(t in l,
+ "#1703448 triggered after %d trials: %s" % (i, l))
+ finally:
+ sys.setcheckinterval(old_interval)
+
+
class ThreadingExceptionTests(unittest.TestCase):
# A RuntimeError should be raised if Thread.start() is called
# multiple times.