diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-27 23:55:59 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-04-27 23:55:59 +0000 |
commit | 6a10281d3359de890519c23d0318742018c843a3 (patch) | |
tree | 71fdda13733f42f287602b72b60260cdc9afa6ba /Lib/test/test_io.py | |
parent | c73a05f775013980a2a0de1c2a65b8542ee0bfa6 (diff) | |
download | cpython-git-6a10281d3359de890519c23d0318742018c843a3.tar.gz |
Issue #7449, last part (11): fix many tests if thread support is disabled
* Use try/except ImportError or test_support.import_module() to import thread
and threading modules
* Add @unittest.skipUnless(threading, ...) to testcases using threads
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 9ffe646ea9..b3feb1b065 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -26,7 +26,6 @@ import os import sys import time import array -import threading import random import unittest import weakref @@ -38,6 +37,10 @@ from test import test_support as support import codecs import io # C implementation of io import _pyio as pyio # Python implementation of io +try: + import threading +except ImportError: + threading = None __metaclass__ = type bytes = support.py3k_bytes @@ -749,6 +752,7 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests): self.assertEquals(b"abcdefg", bufio.read()) + @unittest.skipUnless(threading, 'Threading required for this test.') def test_threads(self): try: # Write out many bytes with exactly the same number of 0's, @@ -996,6 +1000,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests): with self.open(support.TESTFN, "rb", buffering=0) as f: self.assertEqual(f.read(), b"abc") + @unittest.skipUnless(threading, 'Threading required for this test.') def test_threads(self): try: # Write out many bytes from many threads and test they were @@ -2090,7 +2095,7 @@ class TextIOWrapperTest(unittest.TestCase): with self.open(support.TESTFN, "w", errors="replace") as f: self.assertEqual(f.errors, "replace") - + @unittest.skipUnless(threading, 'Threading required for this test.') def test_threads_write(self): # Issue6750: concurrent writes could duplicate data event = threading.Event() |