bpo-27115: Use Query subclass for IDLE editor Goto (GH-18871) · python/cpython@363fab8 (original) (raw)

`@@ -138,6 +138,33 @@ def test_good_module_name(self):

`

138

138

`self.assertEqual(dialog.entry_error['text'], '')

`

139

139

``

140

140

``

``

141

`+

class GotoTest(unittest.TestCase):

`

``

142

`+

"Test Goto subclass of Query."

`

``

143

+

``

144

`+

class Dummy_ModuleName:

`

``

145

`+

entry_ok = query.Goto.entry_ok # Function being tested.

`

``

146

`+

def init(self, dummy_entry):

`

``

147

`+

self.entry = Var(value=dummy_entry)

`

``

148

`+

self.entry_error = {'text': ''}

`

``

149

`+

def showerror(self, message):

`

``

150

`+

self.entry_error['text'] = message

`

``

151

+

``

152

`+

def test_bogus_goto(self):

`

``

153

`+

dialog = self.Dummy_ModuleName('a')

`

``

154

`+

self.assertEqual(dialog.entry_ok(), None)

`

``

155

`+

self.assertIn('not a base 10 integer', dialog.entry_error['text'])

`

``

156

+

``

157

`+

def test_bad_goto(self):

`

``

158

`+

dialog = self.Dummy_ModuleName('0')

`

``

159

`+

self.assertEqual(dialog.entry_ok(), None)

`

``

160

`+

self.assertIn('not a positive integer', dialog.entry_error['text'])

`

``

161

+

``

162

`+

def test_good_goto(self):

`

``

163

`+

dialog = self.Dummy_ModuleName('1')

`

``

164

`+

self.assertEqual(dialog.entry_ok(), 1)

`

``

165

`+

self.assertEqual(dialog.entry_error['text'], '')

`

``

166

+

``

167

+

141

168

`# 3 HelpSource test classes each test one method.

`

142

169

``

143

170

`class HelpsourceBrowsefileTest(unittest.TestCase):

`

`@@ -363,6 +390,22 @@ def test_click_module_name(self):

`

363

390

`root.destroy()

`

364

391

``

365

392

``

``

393

`+

class GotoGuiTest(unittest.TestCase):

`

``

394

+

``

395

`+

@classmethod

`

``

396

`+

def setUpClass(cls):

`

``

397

`+

requires('gui')

`

``

398

+

``

399

`+

def test_click_module_name(self):

`

``

400

`+

root = Tk()

`

``

401

`+

root.withdraw()

`

``

402

`+

dialog = query.Goto(root, 'T', 't', _utest=True)

`

``

403

`+

dialog.entry.insert(0, '22')

`

``

404

`+

dialog.button_ok.invoke()

`

``

405

`+

self.assertEqual(dialog.result, 22)

`

``

406

`+

root.destroy()

`

``

407

+

``

408

+

366

409

`class HelpsourceGuiTest(unittest.TestCase):

`

367

410

``

368

411

`@classmethod

`