def __init__(self): super(OutlineDialog, self).__init__(join_to_file_dir(__file__, 'outline.glade')) self.shortcuts = ShortcutActivator(self.window) self.shortcuts.bind('Escape', self.hide) self.shortcuts.bind('<alt>s', self.focus_search) set_activate_the_one_item(self.search_entry, self.outline_tree)
def test_runner_must_return_collected_tests(): result = collect_results(*run_test(join_to_file_dir(__file__), files=['python_test/first.py'])) assert result[0][0] == ('START') assert result[1] == ('COLLECTED_TESTS', ['python_test/first.py::test_first', 'python_test/first.py::test_second', 'python_test/first.py::test_third', 'python_test/first.py::test_fourth'])
def __init__(self, prefs): BuilderAware.__init__(self, join_to_file_dir(__file__, 'editor_prefs.glade')) self.activator = shortcuts.ShortcutActivator(self.window) self.activator.bind('Escape', self.hide) self.prefs = prefs self.original_prefs = prefs.copy() self.langs.append(('default', )) lm = gtksourceview2.language_manager_get_default() for lang_id in sorted(lm.get_language_ids()): self.langs.append((lang_id, )) sm = gtksourceview2.style_scheme_manager_get_default() for style_id in sm.get_scheme_ids(): self.styles.append((style_id, )) self.checks = ['use-tabs', 'show-right-margin', 'show-line-numbers', 'wrap-text', 'highlight-current-line', 'show-whitespace', 'remove-trailing-space'] for name in self.checks: getattr(self, name.replace('-', '_')).connect( 'toggled', self.on_checkbox_toggled, name) self.margin_width.connect('value-changed', self.on_spin_changed, 'right-margin') self.tab_width.connect('value-changed', self.on_spin_changed, 'tab-width') self.line_spacing.connect('value-changed', self.on_spin_changed, 'line-spacing') self.font.connect('font-set', self.on_font_set, 'font') for h in on_dialog_created_hooks: h(self)
def test_provider_must_resolve_params_of_handlers_defined_in_glade_file_with_external_map(project): project.db.add_class('module.Window', join_to_file_dir(__file__, 'pygtktest', 'sample2.glade')) result = pset(get_proposals(project, 'pass\n\n' ' def on_window2_delete_event(self, wnd):\n' ' wnd.')) assert 'set_title' in result
def select_session(): import gtk from snaked.util import join_to_file_dir from snaked.core.prefs import get_settings_path builder = gtk.Builder() builder.add_from_file(join_to_file_dir(__file__, 'gui', 'select_session.glade')) dialog = builder.get_object('dialog') dialog.vbox.remove(dialog.action_area) dialog.set_default_response(1) sessions_view = builder.get_object('sessions_view') sessions = builder.get_object('sessions') for p in os.listdir(get_settings_path('')): if p.endswith('.session'): sessions.append((p.rpartition('.')[0],)) def row_activated(view, path, *args): dialog.response(path[0]) sessions_view.connect('row-activated', row_activated) response = dialog.run() result = sessions[response][0] if response >= 0 else None dialog.destroy() return result
def test_runner_must_return_right_status_for_failed_collect(): result = collect_results(*run_test(join_to_file_dir(__file__), files=['python_test/module_with_errors.py'])) assert result[1][0] == 'FAILED_COLLECT' assert result[1][1] == 'python_test/module_with_errors.py' assert result[1][3] == [('python_test/module_with_errors.py', 4)] assert 'NameError' in result[1][2]
def on_editor_get_project_larva(editor): from snaked.util import join_to_file_dir import os.path if os.path.exists(join_to_file_dir(editor.uri, '__init__.py')): editor.get_project_larva.stop_emission() root, packages = get_package_root(editor.uri) return os.path.join(root, packages.partition('.')[0])
def __init__(self, existing_snippets): BuilderAware.__init__(self, join_to_file_dir(__file__, 'prefs.glade')) from snaked.core.shortcuts import ShortcutActivator self.activator = ShortcutActivator(self.window) self.activator.bind('Escape', self.hide) self.activator.bind('<alt>s', self.focus_search) self.existing_snippets = existing_snippets set_activate_the_one_item(self.search_entry, self.snippets_view)
def test_class_must_contain_objects_defined_in_glade_file_with_external_mapping(project): project.db.add_class('module.Window', join_to_file_dir(__file__, 'pygtktest', 'sample2.glade')) result = pset(get_proposals(project, 'self.')) assert 'window2' in result assert 'vbox2' in result result = pset(get_proposals(project, 'self.window2.')) assert 'set_title' in result result = pset(get_proposals(project, 'self.vbox2.')) assert 'pack_start' in result
def test_runner_must_return_runned_test_results(): result = collect_results(*run_test(join_to_file_dir(__file__), files=['python_test/first.py'])) assert result[2] == ('ITEM_CALL', 'python_test/first.py::test_first') assert result[3] == ('PASS', 'python_test/first.py::test_first') assert result[6] == ('ITEM_CALL', 'python_test/first.py::test_third') assert result[7] == ('SKIP', 'python_test/first.py::test_third') assert result[5][:2] == ('FAIL', 'python_test/first.py::test_second') assert 'AssertionError' in result[5][2] assert result[9][:2] == ('FAIL', 'python_test/first.py::test_fourth') assert 'AttributeError' in result[9][2]
def get_proposals(project, source, offset=None, **kwargs): head = 'from scopetest import *\n\n' source = head + source if offset is None: offset = len(source) else: offset += len(head) resource = NoProject().get_file(join_to_file_dir(__file__, 'module.py')) resource.read = lambda: '' return code_assist(project, source, offset, resource=resource, **kwargs)
def __init__(self): super(QuickOpenDialog, self).__init__(join_to_file_dir(__file__, 'gui.glade')) self.shortcuts = ShortcutActivator(self.window) self.shortcuts.bind('Escape', self.escape) self.shortcuts.bind('<alt>Up', self.project_up) self.shortcuts.bind('<alt>Down', self.project_down) self.shortcuts.bind('<ctrl>Return', self.open_mime) self.shortcuts.bind('<alt>s', self.focus_search) self.shortcuts.bind('<ctrl>o', self.free_open) self.shortcuts.bind('<ctrl>p', self.popup_projects) self.shortcuts.bind('<ctrl>Delete', self.delete_project) self.shortcuts.bind('<ctrl>h', self.toggle_hidden) self.shortcuts.bind('BackSpace', self.browse_top) set_activate_the_one_item(self.search_entry, self.filelist_tree)
def __init__(self): super(TestRunner, self).__init__(join_to_file_dir(__file__, 'pytest_runner.glade')) self.buffer = gtk.TextBuffer() self.view = gtk.TextView() self.view.set_buffer(self.buffer) self.view.set_editable(False) self.view.set_wrap_mode(gtk.WRAP_WORD) self.buffer_place.add(self.view) self.view.show() self.editor_ref = None self.timer_id = None self.test_proc = None self.collected_nodes = {} self.failed_nodes = {} self.nodes_traces = {} self.nodes_buffer_positions = {} self.panel.hide() self.escape = None
def get_proposals(project, source, offset=None, **kwargs): head = ( 'class Window(object):\n' ' """glade-file: sample.glade"""\n' '\n' ' def func(self):\n' ' ' ) source = head + source if offset is None: offset = len(source) else: offset += len(head) resource = NoProject().get_file(join_to_file_dir(__file__, 'pygtktest', 'module.py')) resource.read = lambda: '' return code_assist(project, source, offset, resource=resource, **kwargs)
def __init__(self): super(EditorListDialog, self).__init__(join_to_file_dir(__file__, 'gui.glade')) self.shortcuts = ShortcutActivator(self.window) self.shortcuts.bind('Escape', self.hide) self.shortcuts.bind('Delete', self.close_editor) self.editor = None self.block_cursor = False self.path2uri = {} self.paths = [] self.editors_view.set_search_equal_func(search_func) self.editors_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.mnemonic_renderer.set_property('yalign', 0.5) self.mnemonic_renderer.set_property('weight', pango.WEIGHT_BOLD) self.mnemonic_renderer.set_property('width', 5) self.mnemonic_hole.set_property('width', 20) for i, m in enumerate(mnemonics): self.shortcuts.bind('<alt>'+m, self.mnemonic_activate, i)
def test_runner_must_ignore_skipped_collected_items(): result = collect_results(*run_test(join_to_file_dir(__file__), None, 'test_first', files=['python_test/first.py'])) assert result[1] == ('COLLECTED_TESTS', ['python_test/first.py::test_first'])
def __init__(self): BuilderAware.__init__(self, join_to_file_dir(__file__, 'plugin_prefs.glade')) self.activator = ShortcutActivator(self.window) self.activator.bind('Escape', self.hide) self.plugins_tree.get_columns()[0].get_cell_renderers()[0].props.activatable = True
def test_runner_must_return_output_of_failed_tests(): result = collect_results(*run_test(join_to_file_dir(__file__), files=['python_test/first.py'], match='test_second')) assert 'test-second-output' in result[3][2]
def __init__(self): BuilderAware.__init__(self, join_to_file_dir(__file__, 'shortcuts.glade')) self.activator = shortcuts.ShortcutActivator(self.window) self.activator.bind('Escape', self.hide)