Example #1
0
 def test_networked(self):
     # Default settings: no cert verification is done
     support.requires('network')
     with support.transient_internet('svn.python.org'):
         h = client.HTTPSConnection('svn.python.org', 443)
         h.request('GET', '/')
         resp = h.getresponse()
         self._check_svn_python_org(resp)
Example #2
0
 def test_networked_bad_cert(self):
     # We feed a "CA" cert that is unrelated to the server's cert
     import ssl
     support.requires('network')
     with support.transient_internet('svn.python.org'):
         context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
         context.verify_mode = ssl.CERT_REQUIRED
         context.load_verify_locations(CERT_localhost)
         h = client.HTTPSConnection('svn.python.org', 443, context=context)
         with self.assertRaises(ssl.SSLError):
             h.request('GET', '/')
Example #3
0
 def test_networked_good_cert(self):
     # We feed a CA cert that validates the server's cert
     import ssl
     support.requires('network')
     with support.transient_internet('svn.python.org'):
         context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
         context.verify_mode = ssl.CERT_REQUIRED
         context.load_verify_locations(CACERT_svn_python_org)
         h = client.HTTPSConnection('svn.python.org', 443, context=context)
         h.request('GET', '/')
         resp = h.getresponse()
         self._check_svn_python_org(resp)
# -*- encoding: utf8 -*-
import unittest
import ttk

from support import simulate_mouse_click, requires, run_unittest, text
from test_functions import MockTclObj, MockStateSpec

Tkinter = ttk.Tkinter
requires('gui')

class WidgetTest(unittest.TestCase):
    """Tests methods available in every ttk widget."""

    def setUp(self):
        self.widget = ttk.Button(text='Label')
        self.widget.pack()
        self.widget.wait_visibility()

    def tearDown(self):
        self.widget.destroy()


    def test_identify(self):
        self.widget.update_idletasks()
        self.assertEqual(self.widget.identify(20, 7), "label")
        self.assertEqual(self.widget.identify(-1, -1), "")

        self.assertRaises(Tkinter.TclError, self.widget.identify, None, 5)
        self.assertRaises(Tkinter.TclError, self.widget.identify, 5, None)
        self.assertRaises(Tkinter.TclError, self.widget.identify, 5, '')
import sys
import unittest
import ttk

from support import get_tk_root, requires, run_unittest

Tkinter = ttk.Tkinter
requires('gui')

class StyleTest(unittest.TestCase):

    def setUp(self):
        self.root = get_tk_root()
        self.style = ttk.Style(self.root)

    def tearDown(self):
        # As tests have shown, these tests are likely to deliver
        # <<ThemeChanged>> events after the root is destroyed, so
        # lets let them happen now.
        self.root.update_idletasks()
        self.root.destroy()


    def test_configure(self):
        style = self.style
        style.configure('TButton', background='yellow')
        self.assertEqual(style.configure('TButton', 'background'),
            'yellow')
        self.assertTrue(isinstance(style.configure('TButton'), dict))