<s> from __future__ import absolute_import <EOL> import os <EOL> import sys <EOL> from traits . testing . unittest_tools import unittest , UnittestTools <EOL> from . . gui import GUI <EOL> from . . python_editor import PythonEditor <EOL> from . . window import Window <EOL> PYTHON_SCRIPT = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> class TestPythonEditor ( unittest . TestCase , UnittestTools ) : <EOL> def setUp ( self ) : <EOL> self . gui = GUI ( ) <EOL> self . window = Window ( ) <EOL> self . window . _create ( ) <EOL> def tearDown ( self ) : <EOL> self . widget . destroy ( ) <EOL> self . window . destroy ( ) <EOL> def test_lifecycle ( self ) : <EOL> self . widget = PythonEditor ( self . window . control ) <EOL> self . gui . process_events ( ) <EOL> self . assertFalse ( self . widget . dirty ) <EOL> self . widget . destroy ( ) <EOL> self . gui . process_events ( ) <EOL> def test_show_line_numbers ( self ) : <EOL> self . widget = PythonEditor ( self . window . control , show_line_numbers = False ) <EOL> self . gui . process_events ( ) <EOL> self . widget . show_line_numbers = True <EOL> self . gui . process_events ( ) <EOL> self . widget . show_line_numbers = False <EOL> self . gui . process_events ( ) <EOL> self . widget . destroy ( ) <EOL> self . gui . process_events ( ) <EOL> def test_load ( self ) : <EOL> self . widget = PythonEditor ( self . window . control ) <EOL> self . gui . process_events ( ) <EOL> with self . assertTraitChanges ( self . widget , '<STR_LIT>' , count = <NUM_LIT:1> ) : <EOL> self . widget . path = PYTHON_SCRIPT <EOL> self . assertFalse ( self . widget . dirty ) <EOL> self . widget . destroy ( ) <EOL> self . gui . process_events ( ) <EOL> def test_select_line ( self ) : <EOL> self . widget = PythonEditor ( self . window . control , path = PYTHON_SCRIPT ) <EOL> self . gui . process_events ( ) <EOL> self . widget . select_line ( <NUM_LIT:3> ) <EOL> self . widget . destroy ( ) <EOL> self . gui . process_events ( ) </s>
