def test_main(): support.requires('network') support.run_unittest( CreationTestCase, TCPTimeoutTestCase, UDPTimeoutTestCase, )
def setUpModule(): try: import signal # The default handler for SIGXFSZ is to abort the process. # By ignoring it, system calls exceeding the file size resource # limit will raise OSError instead of crashing the interpreter. signal.signal(signal.SIGXFSZ, signal.SIG_IGN) except (ImportError, AttributeError): pass # On Windows and Mac OSX this test comsumes large resources; It # takes a long time to build the >2GB file and takes >2GB of disk # space therefore the resource must be enabled to run this test. # If not, nothing after this line stanza will be executed. if sys.platform[:3] == 'win' or sys.platform == 'darwin': requires('largefile', 'test requires %s bytes and a long time to run' % str(size)) else: # Only run if the current filesystem supports large files. # (Skip this test on Windows, since we now always support # large files.) f = open(TESTFN, 'wb', buffering=0) try: # 2**31 == 2147483648 f.seek(2147483649) # Seeking is not enough of a test: you must write and flush, too! f.write(b'x') f.flush() except (OSError, OverflowError): raise unittest.SkipTest("filesystem does not have " "largefile support") finally: f.close() unlink(TESTFN)
def setUpClass(cls): if 'tkinter' in str(Text): requires('gui') cls.tk = Tk() cls.text = Text(cls.tk) else: cls.text = Text() cls.auto_expand = AutoExpand(Dummy_Editwin(cls.text)) cls.auto_expand.bell = lambda: None
def setUpClass(cls): requires('gui') cls.root = tk.Tk() cls.root.withdraw() def cmd(tkpath, func): assert isinstance(tkpath, str) assert isinstance(func, type(cmd)) cls.root.createcommand = cmd
def _make_test_file(self, num_zeroes, tail): if sys.platform[:3] == 'win' or sys.platform == 'darwin': requires('largefile', 'test requires %s bytes and a long time to run' % str(0x180000000)) f = open(TESTFN, 'w+b') try: f.seek(num_zeroes) f.write(tail) f.flush() except (OSError, OverflowError, ValueError): try: f.close() except (OSError, OverflowError): pass raise unittest.SkipTest("filesystem does not have largefile support") return f
def setUpClass(cls): requires('gui') cls.root = tk.Tk() cls.root.withdraw()
def test_main(): support.requires("network") support.run_unittest(PythonBuildersTest)
# Only called, not tested: getmouse(), ungetmouse() # import os import string import sys import tempfile import unittest from sql_mode.support import requires, import_module, verbose # Optionally test curses module. This currently requires that the # 'curses' resource be given on the regrtest command line using the -u # option. If not available, nothing after this line will be executed. import inspect requires('curses') # If either of these don't exist, skip the tests. curses = import_module('curses') import_module('curses.panel') import_module('curses.ascii') import_module('curses.textpad') def requires_curses_func(name): return unittest.skipUnless(hasattr(curses, name), 'requires curses.%s' % name) term = os.environ.get('TERM') # If newterm was supported we could use it instead of initscr and not exit @unittest.skipIf(not term or term == 'unknown',
def setUpClass(cls): requires('gui') cls.root = Tk()
def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.text = Text(cls.root) cls.editwin = DummyEditwin(cls.text)
import os import sys import unittest import sql_mode.support as test_support from tkinter import Tcl, TclError test_support.requires('gui') class TkLoadTest(unittest.TestCase): @unittest.skipIf('DISPLAY' not in os.environ, 'No $DISPLAY set.') def testLoadTk(self): tcl = Tcl() self.assertRaises(TclError,tcl.winfo_geometry) tcl.loadtk() self.assertEqual('1x1+0+0', tcl.winfo_geometry()) tcl.destroy() def testLoadTkFailure(self): old_display = None if sys.platform.startswith(('win', 'darwin', 'cygwin')): # no failure possible on windows? # XXX Maybe on tk older than 8.4.13 it would be possible, # see tkinter.h. return with test_support.EnvironmentVarGuard() as env: if 'DISPLAY' in os.environ: del env['DISPLAY'] # on some platforms, deleting environment variables # doesn't actually carry through to the process level
import unittest from sql_mode import support import contextlib import socket import urllib.request import os import email.message import time support.requires('network') class URLTimeoutTest(unittest.TestCase): # XXX this test doesn't seem to test anything useful. TIMEOUT = 30.0 def setUp(self): socket.setdefaulttimeout(self.TIMEOUT) def tearDown(self): socket.setdefaulttimeout(None) def testURLread(self): with support.transient_internet("www.example.com"): f = urllib.request.urlopen("http://www.example.com/") f.read()
# Tests of the full ZIP64 functionality of zipfile # The support.requires call is the only reason for keeping this separate # from test_zipfile from sql_mode import support # XXX(nnorwitz): disable this test by looking for extralargefile resource, # which doesn't exist. This test takes over 30 minutes to run in general # and requires more disk space than most of the buildbots. support.requires( 'extralargefile', 'test requires loads of disk-space bytes and a long time to run') import zipfile, os, unittest import time import sys from io import StringIO from tempfile import TemporaryFile from sql_mode.support import TESTFN, requires_zlib TESTFN2 = TESTFN + "2" # How much time in seconds can pass before we print a 'Still working' message. _PRINT_WORKING_MSG_INTERVAL = 5 * 60 class TestsWithSourceFile(unittest.TestCase): def setUp(self): # Create test data. line_gen = ("Test of zipfile line %d." % i for i in range(1000000))
def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.dialog = About(cls.root, 'About IDLE', _utest=True)
def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.text = Text(cls.root)
def setUpClass(cls): requires('gui')
def setUpClass(cls): requires('gui') cls.root = root = Tk() cls.root.withdraw() cls.dialog = query.Query(root, 'TEST', 'test', _utest=True) cls.dialog.destroy = mock.Mock()
def setUpClass(cls): requires('gui') cls.root = Tk() cls.text = Text(cls.root) cls.editor = DummyEditwin(cls.root, cls.text)
"""Test SearchDialog class in idlelib.search.py""" # Does not currently test the event handler wrappers. # A usage test should simulate clicks and check hilighting. # Tests need to be coordinated with SearchDialogBase tests # to avoid duplication. from sql_mode.support import requires requires('gui') import unittest import tkinter as tk from tkinter import BooleanVar import idlelib.searchengine as se import idlelib.search as sd class SearchDialogTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.root = tk.Tk() @classmethod def tearDownClass(cls): cls.root.destroy() del cls.root def setUp(self): self.engine = se.SearchEngine(self.root) self.dialog = sd.SearchDialog(self.root, self.engine) self.dialog.bell = lambda: None
def setUpClass(cls): requires('gui') from tkinter import Tk, Text cls.Text = Text cls.root = Tk()
def setUpClass(cls): support.requires('network') with support.transient_internet(cls.base_url): cls.parser = urllib.robotparser.RobotFileParser(cls.robots_txt) cls.parser.read()
import unittest from sql_mode import support from sql_mode.test_urllib2 import sanepathname2url import os import socket import urllib.error import urllib.request import sys support.requires("network") TIMEOUT = 60 # seconds def _retry_thrice(func, exc, *args, **kwargs): for i in range(3): try: return func(*args, **kwargs) except exc as e: last_exc = e continue raise last_exc def _wrap_with_retry_thrice(func, exc): def wrapped(*args, **kwargs): return _retry_thrice(func, exc, *args, **kwargs) return wrapped
from sql_mode import support support.requires('audio') from sql_mode.support import findfile ossaudiodev = support.import_module('ossaudiodev') import errno import sys import sunau import time import audioop import unittest # Arggh, AFMT_S16_NE not defined on all platforms -- seems to be a # fairly recent addition to OSS. try: from ossaudiodev import AFMT_S16_NE except ImportError: if sys.byteorder == "little": AFMT_S16_NE = ossaudiodev.AFMT_S16_LE else: AFMT_S16_NE = ossaudiodev.AFMT_S16_BE def read_sound_file(path): with open(path, 'rb') as fp: au = sunau.open(fp) rate = au.getframerate() nchannels = au.getnchannels()
def setUpClass(cls): requires('gui') cls.root = Tk() editor = Editor(root=cls.root) cls.text = editor.text.text # Test code does not need the wrapper. cls.formatter = fp.FormatParagraph(editor).format_paragraph_event
import unittest import tkinter from sql_mode import support from tkinter.test.support import AbstractTkTest support.requires('gui') class MiscTest(AbstractTkTest, unittest.TestCase): def test_repr(self): t = tkinter.Toplevel(self.root, name='top') f = tkinter.Frame(t, name='child') self.assertEqual(repr(f), '<tkinter.Frame object .top.child>') def test_generated_names(self): t = tkinter.Toplevel(self.root) f = tkinter.Frame(t) f2 = tkinter.Frame(t) b = tkinter.Button(f2) for name in str(b).split('.'): self.assertFalse(name.isidentifier(), msg=repr(name)) def test_tk_setPalette(self): root = self.root root.tk_setPalette('black') self.assertEqual(root['background'], 'black') root.tk_setPalette('white') self.assertEqual(root['background'], 'white') self.assertRaisesRegex(tkinter.TclError, '^unknown color name "spam"$', root.tk_setPalette, 'spam')
def setUpClass(cls): requires('gui') cls.root = tk.Tk() cls.root.withdraw() cls.orig_platform = macosx.platform