<commit_before>import unittest

# Do a dance to force ETS to use Qt and make sure that enaml imports Qt first.
from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'
import enaml.qt  # NOQA

from enable.testing import EnableTestAssistant
from enable.window import Window
from traits_enaml.testing.gui_test_assistant import GuiTestAssistant

from ensemble.ctf.editor import CtfEditor


def get_color(starting_color=None):
    if starting_color:
        return starting_color
    return (0.0, 1.0, 0.0)


def get_filename(action='save'):
    return 'temp.json'


class TestCtfEditor(EnableTestAssistant, GuiTestAssistant, unittest.TestCase):

    def setUp(self):
        super(TestCtfEditor, self).setUp()

        tool = CtfEditor(bounds=(400, 100),
                         prompt_color_selection=get_color,
                         prompt_file_selection=get_filename)
        tool.add_function_node(tool.opacities, (0.5, 0.5))
        tool.add_function_node(tool.colors, (0.25, 1.0, 0.0, 0.0))
        self.tool = tool
        self.window = Window(None, size=(100, 100), component=tool)
        with self.event_loop():
            self.window.control.show()

    def test_mouse_drag_alpha(self):
        tool = self.tool
        self.press_move_release(tool, [(50, 50), (51, 50), (52, 50),
                                       (53, 50), (54, 50), (55, 50)],
                                window=self.window)

    def test_mouse_drag_color(self):
        tool = self.tool
        self.press_move_release(tool, [(25, 10), (25, 10), (40, 10)],
                                window=self.window)

if __name__ == '__main__':
    unittest.main()
<commit_msg>Try using EnamlTestAssistant to get a real window...<commit_after>import unittest

# Do a dance to force ETS to use Qt and make sure that enaml imports Qt first.
from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'
import enaml.qt  # NOQA

from enable.testing import EnableTestAssistant
from traits_enaml.testing.enaml_test_assistant import EnamlTestAssistant

from ensemble.ctf.editor import CtfEditor


def get_color(starting_color=None):
    if starting_color:
        return starting_color
    return (0.0, 1.0, 0.0)


def get_filename(action='save'):
    return 'temp.json'


class TestEditor(EnamlTestAssistant, EnableTestAssistant, unittest.TestCase):

    def setUp(self):
        EnamlTestAssistant.setUp(self)

        enaml_source = """
from enaml.widgets.api import MainWindow
from traits_enaml.widgets.enable_canvas import EnableCanvas

enamldef MainView(MainWindow):
    attr editor

    EnableCanvas:
        component << editor
"""

        editor = CtfEditor(bounds=(400, 100),
                           prompt_color_selection=get_color,
                           prompt_file_selection=get_filename)
        editor.add_function_node(editor.opacities, (0.5, 0.5))
        editor.add_function_node(editor.colors, (0.25, 1.0, 0.0, 0.0))
        self.editor = editor
        self.view, _ = self.parse_and_create(enaml_source, editor=self.editor)

        with self.event_loop():
            self.view.show()

    def tearDown(self):
        self.editor = None
        self.view = None

        EnamlTestAssistant.tearDown(self)

    def test_mouse_drag_alpha(self):
        editor = self.editor
        self.press_move_release(editor, [(50, 50), (51, 50), (52, 50),
                                         (53, 50), (54, 50), (55, 50)],
                                window=editor.window)

    def test_mouse_drag_color(self):
        editor = self.editor
        self.press_move_release(editor, [(25, 10), (25, 10), (40, 10)],
                                window=editor.window)

if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.10355900454910356, 'fraction_numerical': 0.034787262510034785, 'mean_word_length': 2.5364238410596025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7568113', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1138, 'n_words': 269}