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
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 9ffe646..b3feb1b 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -26,7 +26,6 @@
 import sys
 import time
 import array
-import threading
 import random
 import unittest
 import weakref
@@ -38,6 +37,10 @@
 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 @@
 
         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 @@
         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 @@
         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()