Пример #1
0
    def test_goto_file_line(self):
        eq = self.assertEqual
        w = self.window
        text = self.text

        w.flist = mock.Mock()
        gfl = w.flist.gotofileline = Func()
        showerror = w.showerror = Mbox_func()

        # No file/line number.
        w.write('Not a file line')
        self.assertIsNone(w.goto_file_line())
        eq(gfl.called, 0)
        eq(showerror.title, 'No special line')

        # Current file/line number.
        w.write(f'{str(__file__)}: 42: spam\n')
        w.write(f'{str(__file__)}: 21: spam')
        self.assertIsNone(w.goto_file_line())
        eq(gfl.args, (str(__file__), 21))

        # Previous line has file/line number.
        text.delete('1.0', 'end')
        w.write(f'{str(__file__)}: 42: spam\n')
        w.write('Not a file line')
        self.assertIsNone(w.goto_file_line())
        eq(gfl.args, (str(__file__), 42))

        del w.flist.gotofileline, w.showerror
Пример #2
0
 def setUpClass(cls):
     cls.orig_error = textview.showerror
     cls.orig_view = textview.view_text
     cls.error = Mbox_func()
     cls.view = Func()
     textview.showerror = cls.error
     textview.view_text = cls.view
Пример #3
0
 def setUpClass(cls):
     cls.orig_error = textview.showerror
     cls.orig_view = textview.view_text
     cls.error = Mbox_func()
     cls.view = Func()
     textview.showerror = cls.error
     textview.view_text = cls.view
     cls.About = Dummy_about_dialog()
Пример #4
0
 class Validator(config_key.GetKeysDialog):
     def __init__(self, *args, **kwargs):
         config_key.GetKeysDialog.__init__(self, *args, **kwargs)
         class listKeysFinal:
             get = Func()
         self.listKeysFinal = listKeysFinal
     GetModifiers = Func()
     showerror = Mbox_func()
Пример #5
0
 class Basic(gkd):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
         class list_keys_final:
             get = Func()
             select_clear = Func()
             yview = Func()
         self.list_keys_final = list_keys_final
     def set_modifiers_for_platform(self):
         self.modifiers = ['foo', 'bar', 'BAZ']
         self.modifier_label = {'BAZ': 'ZZZ'}
     showerror = Mbox_func()
Пример #6
0
 def setUpClass(cls):
     cls.orig_error = tv.showerror
     tv.showerror = Mbox_func()
Пример #7
0
Coverage: 94% (100% for Query and SectionName).
6 of 8 missing are ModuleName exceptions I don't know how to trigger.
"""
from test.support import requires
from tkinter import Tk
import unittest
from unittest import mock
from idlelib.idle_test.mock_tk import Var, Mbox_func
from idlelib import query

# Mock entry.showerror messagebox so don't need click to continue
# when entry_ok and path_ok methods call it to display errors.

orig_showerror = query.showerror
showerror = Mbox_func()  # Instance has __call__ method.

def setUpModule():
    query.showerror = showerror

def tearDownModule():
    query.showerror = orig_showerror


# NON-GUI TESTS

class QueryTest(unittest.TestCase):
    "Test Query base class."

    class Dummy_Query:
        # Test the following Query methods.