def __init__(self, *args, **kw): unittest.TestCase.__init__(self, *args, **kw) try: self.open_mapping_file() # test it to report the error early except IOError: raise test_support.TestSkipped("Could not retrieve " + self.mapfileurl)
def test_main(verbose=False): if skip_expected: raise test_support.TestSkipped("No SSL support") global CERTFILE, TESTPORT, SVN_PYTHON_ORG_ROOT_CERT CERTFILE = os.path.join( os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "root.crt") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)): raise test_support.TestFailed("Can't read certificate files!") TESTPORT = findtestsocket(10025, 12000) if not TESTPORT: raise test_support.TestFailed( "Can't find open port to test servers on!") tests = [BasicTests] if test_support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: if CERTFILE and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) test_support.run_unittest(*tests)
def test_main(verbose=False): if skip_expected: raise test_support.TestSkipped("No SSL support") global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "https_svn_python_org_root.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)): raise test_support.TestFailed("Can't read certificate files!") TESTPORT = test_support.find_unused_port() if not TESTPORT: raise test_support.TestFailed("Can't find open port to test servers on!") tests = [BasicTests] if test_support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = test_support.threading_setup() if thread_info and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) test_support.run_unittest(*tests) if _have_threads: test_support.threading_cleanup(*thread_info)
def testPutEnv(self): "Put an environment variable and ensure that spawned processes see the change" value = "Value we set" os.putenv("NEWVARIABLE", value) newValue = os.popen("echo $NEWVARIABLE").read().strip() if newValue == "$NEWVARIABLE": newValue = os.popen("echo %NEWVARIABLE%").read().strip() if newValue == "%NEWVARIABLE%": raise test_support.TestSkipped( "Unable to find a subshell to execute echo") assert newValue == value, ("Expected (%s) to equal value we set (%s)" % (newValue, value))
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ Tests for epoll wrapper. """ import os import socket import errno import time import select import tempfile import unittest from test import test_support if not hasattr(select, "epoll"): raise test_support.TestSkipped("test works only on Linux 2.6") try: select.epoll() except IOError, e: if e.errno == errno.ENOSYS: raise test_support.TestSkipped("kernel doesn't support epoll()") class TestEPoll(unittest.TestCase): def setUp(self): self.serverSocket = socket.socket() self.serverSocket.bind(('127.0.0.1', 0)) self.serverSocket.listen(1) self.connections = [self.serverSocket]
from __future__ import with_statement import unittest from test import test_support from contextlib import closing, nested import gc import pickle import select import signal import subprocess import traceback import sys, os, time, errno if (sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos' or (test_support.is_jython and os._name == 'nt')): raise test_support.TestSkipped("Can't test signal on %s" % \ sys.platform) class HandlerBCalled(Exception): pass def exit_subprocess(): """Use os._exit(0) to exit the current subprocess. Otherwise, the test catches the SystemExit and continues executing in parallel with the original test, so you wind up with an exponential number of tests running concurrently. """ os._exit(0)
def test_main(): if not hasattr(socket, "ssl"): raise test_support.TestSkipped("socket module has no ssl support") test_rude_shutdown() test_basic() test_timeout()
""" Tests for kqueue wrapper. """ import socket import errno import time import select import sys import unittest from test import test_support if not hasattr(select, "kqueue"): raise test_support.TestSkipped("test works only on BSD") class TestKQueue(unittest.TestCase): def test_create_queue(self): kq = select.kqueue() self.assert_(kq.fileno() > 0, kq.fileno()) self.assert_(not kq.closed) kq.close() self.assert_(kq.closed) self.assertRaises(ValueError, kq.fileno) def test_create_event(self): fd = sys.stderr.fileno() ev = select.kevent(fd) other = select.kevent(1000) self.assertEqual(ev.ident, fd) self.assertEqual(ev.filter, select.KQ_FILTER_READ) self.assertEqual(ev.flags, select.KQ_EV_ADD) self.assertEqual(ev.fflags, 0)
def test_main(): if (os._name if test_support.is_jython else os.name) != 'nt': raise test_support.TestSkipped('NT specific test') test_support.run_unittest(NTAbspathTestCase)
def __init__(self, *args, **kw): unittest.TestCase.__init__(self, *args, **kw) if not os.path.exists(self.mapfilename): raise test_support.TestSkipped('%s not found, download from %s' % (self.mapfilename, self.mapfileurl))
def test_main(): # Skip on wide unicode if len(u'\0'.encode('unicode-internal')) == 4: raise test_support.TestSkipped("test_macostools is broken in USC4") test_support.run_unittest(TestMacostools)
import os import sys import ttk from _tkinter import TclError from test import test_support try: ttk.Button() except TclError, msg: # assuming ttk is not available raise test_support.TestSkipped("ttk not available: %s" % msg) this_dir = os.path.dirname(os.path.abspath(__file__)) lib_tk_test = os.path.abspath( os.path.join(this_dir, os.path.pardir, 'lib-tk', 'test')) if lib_tk_test not in sys.path: sys.path.append(lib_tk_test) import runtktests def test_main(enable_gui=False): if enable_gui: if test_support.use_resources is None: test_support.use_resources = ['gui'] elif 'gui' not in test_support.use_resources: test_support.use_resources.append('gui') test_support.run_unittest( *runtktests.get_tests(text=False, packages=['test_ttk']))