summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/test_array.py35
-rw-r--r--Lib/test/test_pkgutil.py6
-rw-r--r--Lib/test/test_subprocess.py18
3 files changed, 58 insertions, 1 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 7ae34a9..3dd4f6d 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -272,6 +272,12 @@ class BaseTest(unittest.TestCase):
a,
array.array(self.typecode, self.example[::-1]+2*self.example)
)
+ a = array.array(self.typecode, self.example)
+ a += a
+ self.assertEqual(
+ a,
+ array.array(self.typecode, self.example + self.example)
+ )
b = array.array(self.badtypecode())
self.assertRaises(TypeError, a.__add__, b)
@@ -667,6 +673,13 @@ class BaseTest(unittest.TestCase):
array.array(self.typecode, self.example+self.example[::-1])
)
+ a = array.array(self.typecode, self.example)
+ a.extend(a)
+ self.assertEqual(
+ a,
+ array.array(self.typecode, self.example+self.example)
+ )
+
b = array.array(self.badtypecode())
self.assertRaises(TypeError, a.extend, b)
@@ -749,9 +762,31 @@ class BaseTest(unittest.TestCase):
ArraySubclassWithKwargs('b', newarg=1)
def test_create_from_bytes(self):
+ # XXX This test probably needs to be moved in a subclass or
+ # generalized to use self.typecode.
a = array.array('H', b"1234")
self.assertEqual(len(a) * a.itemsize, 4)
+ def test_memoryview_no_resize(self):
+ # Test for issue 4509.
+ a = array.array(self.typecode, self.example)
+ m = memoryview(a)
+ expected = m.tobytes()
+ self.assertRaises(BufferError, a.pop, 0)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.remove, a[0])
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.__setitem__, slice(0, 0), a)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.__delitem__, slice(0, len(a)))
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.__imul__, 2)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.__iadd__, a)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.extend, a)
+ self.assertEqual(m.tobytes(), expected)
+
class StringTest(BaseTest):
diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py
index 169ef66..f69af5a 100644
--- a/Lib/test/test_pkgutil.py
+++ b/Lib/test/test_pkgutil.py
@@ -74,6 +74,12 @@ class PkgutilTests(unittest.TestCase):
self.assertEqual(res1, RESOURCE_DATA)
res2 = pkgutil.get_data(pkg, 'sub/res.txt')
self.assertEqual(res2, RESOURCE_DATA)
+
+ names = []
+ for loader, name, ispkg in pkgutil.iter_modules([zip_file]):
+ names.append(name)
+ self.assertEqual(names, ['test_getdata_zipfile'])
+
del sys.path[0]
del sys.modules[pkg]
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 326c996..f2a396c 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -798,8 +798,24 @@ class CommandTests(unittest.TestCase):
if dir is not None:
os.rmdir(dir)
+
+unit_tests = [ProcessTestCase, CommandTests]
+
+if subprocess._has_poll:
+ class ProcessTestCaseNoPoll(ProcessTestCase):
+ def setUp(self):
+ subprocess._has_poll = False
+ ProcessTestCase.setUp(self)
+
+ def tearDown(self):
+ subprocess._has_poll = True
+ ProcessTestCase.tearDown(self)
+
+ unit_tests.append(ProcessTestCaseNoPoll)
+
+
def test_main():
- support.run_unittest(ProcessTestCase, CommandTests)
+ support.run_unittest(*unit_tests)
support.reap_children()
if __name__ == "__main__":