MCPcopy Index your code
hub / github.com/python/cpython / test_set_region

Method test_set_region

Lib/idlelib/idle_test/test_format.py:453–486  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

451 eq(get(), ('15.0', '16.0', '\n', ['', '']))
452
453 def test_set_region(self):
454 set_ = self.formatter.set_region
455 text = self.text
456 eq = self.assertEqual
457
458 save_bell = text.bell
459 text.bell = mock.Mock()
460 line6 = self.code_sample.splitlines()[5]
461 line10 = self.code_sample.splitlines()[9]
462
463 text.tag_add('sel', '6.0', '11.0')
464 head, tail, chars, lines = self.formatter.get_region()
465
466 # No changes.
467 set_(head, tail, chars, lines)
468 text.bell.assert_called_once()
469 eq(text.get('6.0', '11.0'), chars)
470 eq(text.get('sel.first', 'sel.last'), chars)
471 text.tag_remove('sel', '1.0', 'end')
472
473 # Alter selected lines by changing lines and adding a newline.
474 newstring = 'added line 1\n\n\n\n'
475 newlines = newstring.split('\n')
476 set_('7.0', '10.0', chars, newlines)
477 # Selection changed.
478 eq(text.get('sel.first', 'sel.last'), newstring)
479 # Additional line added, so last index is changed.
480 eq(text.get('7.0', '11.0'), newstring)
481 # Before and after lines unchanged.
482 eq(text.get('6.0', '7.0-1c'), line6)
483 eq(text.get('11.0', '12.0-1c'), line10)
484 text.tag_remove('sel', '1.0', 'end')
485
486 text.bell = save_bell
487
488 def test_indent_region_event(self):
489 indent = self.formatter.indent_region_event

Callers

nothing calls this directly

Calls 8

eqFunction · 0.85
tag_addMethod · 0.80
get_regionMethod · 0.80
assert_called_onceMethod · 0.80
splitlinesMethod · 0.45
getMethod · 0.45
tag_removeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected