summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-04-27 23:33:58 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-04-27 23:33:58 (GMT)
commit47c884129d4b12cd06a5b77c5833b0afee28cd25 (patch)
treee64ad2250455d9d8ede25d81f087ef1c36eecadf
parenta44b5a332620c8fc0fcf25f81025e5f9d832a5e2 (diff)
downloadcpython-47c884129d4b12cd06a5b77c5833b0afee28cd25.zip
cpython-47c884129d4b12cd06a5b77c5833b0afee28cd25.tar.gz
cpython-47c884129d4b12cd06a5b77c5833b0afee28cd25.tar.bz2
Partial revert of r80556 (Issue #7449, part 5, fix ctypes test)
Rewrite r80556: the thread test have to be executed just after the test on libc_open() and so the test cannot be splitted in two functions (without duplicating code, and I don't want to duplicate code).
-rw-r--r--Lib/ctypes/test/test_errno.py42
1 files changed, 19 insertions, 23 deletions
diff --git a/Lib/ctypes/test/test_errno.py b/Lib/ctypes/test/test_errno.py
index 79946d1..c7a5bf0 100644
--- a/Lib/ctypes/test/test_errno.py
+++ b/Lib/ctypes/test/test_errno.py
@@ -7,11 +7,11 @@ try:
except ImportError:
threading = None
-libc_name = find_library("c")
-
class Test(unittest.TestCase):
- @unittest.skipUnless(libc_name, 'Unable to find the C library')
def test_open(self):
+ libc_name = find_library("c")
+ if libc_name is None:
+ raise unittest.SkipTest("Unable to find C library")
libc = CDLL(libc_name, use_errno=True)
if os.name == "nt":
libc_open = libc._open
@@ -26,29 +26,25 @@ class Test(unittest.TestCase):
self.assertEqual(set_errno(32), errno.ENOENT)
self.assertEqual(get_errno(), 32)
- @unittest.skipUnless(libc_name, 'Unable to find the C library')
- @unittest.skipUnless(threading, 'This test requires threading.')
- def test_open_thread(self):
- self.assertEqual(set_errno(32), errno.ENOENT)
-
- def _worker():
- set_errno(0)
+ if threading:
+ def _worker():
+ set_errno(0)
- libc = CDLL(libc_name, use_errno=False)
- if os.name == "nt":
- libc_open = libc._open
- else:
- libc_open = libc.open
- libc_open.argtypes = c_char_p, c_int
- self.assertEqual(libc_open("", 0), -1)
- self.assertEqual(get_errno(), 0)
+ libc = CDLL(libc_name, use_errno=False)
+ if os.name == "nt":
+ libc_open = libc._open
+ else:
+ libc_open = libc.open
+ libc_open.argtypes = c_char_p, c_int
+ self.assertEqual(libc_open("", 0), -1)
+ self.assertEqual(get_errno(), 0)
- t = threading.Thread(target=_worker)
- t.start()
- t.join()
+ t = threading.Thread(target=_worker)
+ t.start()
+ t.join()
- self.assertEqual(get_errno(), 32)
- set_errno(0)
+ self.assertEqual(get_errno(), 32)
+ set_errno(0)
@unittest.skipUnless(os.name == "nt", 'Test specific to Windows')
def test_GetLastError(self):