当前位置: 首页>>代码示例>>Python>>正文


Python Mocker.method方法代码示例

本文整理汇总了Python中mocker.Mocker.method方法的典型用法代码示例。如果您正苦于以下问题:Python Mocker.method方法的具体用法?Python Mocker.method怎么用?Python Mocker.method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mocker.Mocker的用法示例。


在下文中一共展示了Mocker.method方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def do_test(windows_template):
     app = Application()
     m = Mocker()
     seen = set()
     dirty_docs = []
     eds = []
     for ecfg in windows_template:
         projects = []
         for pcfg in ecfg:
             proj = m.mock(Project)
             projects.append(proj)
             editors = []
             has_dirty = False
             for doc_id in pcfg:
                 editor = m.mock(Editor)
                 editors.append(editor)
                 (editor.document.id << doc_id).count(1, 2)
                 if doc_id not in seen:
                     seen.add(doc_id)
                     dirty_docs.append(editor)
                     has_dirty = True
             proj.dirty_editors() >> editors
             if has_dirty:
                 dirty_docs.append(proj)
         ed = m.mock(Window)
         ed.projects >> projects
         eds.append(ed)
     m.method(app.iter_windows)() >> eds
     with m:
         result = list(app.iter_dirty_editors())
         eq_(result, dirty_docs)
开发者ID:editxt,项目名称:editxt,代码行数:33,代码来源:test_application.py

示例2: test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def test(serial):
     m = Mocker()
     proj = Project.create()
     log = m.replace("editxt.project.log", passthrough=False)
     nsdat = m.replace(NSData, passthrough=False)
     nspls = m.replace(NSPropertyListSerialization, passthrough=False)
     create_document_view_with_state = m.method(Project.create_document_view_with_state)
     create_document_view = m.method(Project.create_document_view)
     proj._documents = docs = m.mock(KVOList)
     if "path" in serial:
         data = nsdat.dataWithContentsOfFile_(serial["path"]) >> m.mock()
         serial_, format, error = nspls. \
             propertyListFromData_mutabilityOption_format_errorDescription_( \
                 data, NSPropertyListImmutable, None, None) >> ({}, m.mock(), None)
     else:
         serial_ = serial
     docs_ = serial_.get("documents", [])
     for item in docs_:
         create_document_view_with_state(item)
         if item == "doc_not_found":
             m.throw(Exception("document not found"))
             log.warn("cannot open document: %r" % item)
         #proj._is_dirty = True
     bool(docs); m.result(bool(docs_))
     if not docs_:
         create_document_view()
         #proj._is_dirty = True
     with m:
         proj.deserialize(serial)
         if "path" in serial:
             eq_(proj.path, serial["path"])
             assert "name" not in serial
         else:
             eq_(proj.name, serial.get("name", const.UNTITLED_PROJECT_NAME))
             eq_(proj.expanded, serial.get("expanded", True))
开发者ID:youngrok,项目名称:editxt,代码行数:37,代码来源:test_project.py

示例3: test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def test(eds_config):
     app = Application()
     m = Mocker()
     create_window = m.method(app.create_window)
     open_error_log = m.method(app.open_error_log)
     nsapp = m.mock(ak.NSApplication)
     ud_class = m.replace(fn, 'NSUserDefaults')
     m.method(app.iter_saved_window_states)() >> iter(eds_config)
     tc = m.replace(app, 'text_commander', spec=CommandManager)
     dc = m.mock(DocumentController)
     tc.load_commands(dc.textMenu >> m.mock(ak.NSMenu))
     tc.load_shortcuts(dc.shortcutsMenu >> m.mock(ak.NSMenu))
     if eds_config:
         error = False
         for ed_config in eds_config:
             if isinstance(ed_config, mod.StateLoadFailure):
                 error = True
             else:
                 create_window(ed_config)
         if error:
             open_error_log(set_current=False)
     else:
         create_window()
     with m:
         app.application_will_finish_launching(nsapp, dc)
         eq_(app.text_commander, tc)
开发者ID:editxt,项目名称:editxt,代码行数:28,代码来源:test_application.py

示例4: test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def test(c):
     m = Mocker()
     fc = FindController.shared_controller()
     regexfind = m.method(fc.regexfinditer)
     simplefind = m.method(fc.simplefinditer)
     rfr = m.property(fc, "recently_found_range")
     sel = NSMakeRange(1, 2)
     direction = "<direction>"
     opts = m.property(fc, "opts").value >> m.mock(FindOptions)
     ftext = u"<find>"
     if opts.regular_expression >> c.regex:
         finditer = regexfind
     elif opts.match_entire_word >> c.mword:
         finditer = regexfind
         ftext = u"\\b" + re.escape(ftext) + u"\\b"
     else:
         finditer = simplefind
     range = NSMakeRange(sel.location, 0)
     items = []
     rng = None
     for i, r in enumerate(c.matches):
         if r is WRAPTOKEN:
             items.append(r)
             continue
         found = FoundRange(NSMakeRange(*r))
         items.append(found)
         if i == 0 and found.range == sel:
             continue
         rfr.value = found
         rng = found.range
     finditer(u"<text>", ftext, range, direction, True) >> items
     with m:
         result = fc._find(u"<text>", u"<find>", sel, direction)
         eq_(result, rng)
开发者ID:youngrok,项目名称:editxt,代码行数:36,代码来源:test_findpanel.py

示例5: test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def test(ed_config):
     ac = Application()
     m = Mocker()
     df_class = m.replace("editxt.application.NSUserDefaults")
     iter_editors = m.method(ac.iter_editors)
     save_open_projects = m.method(ac.save_open_projects)
     discard_editor = m.method(ac.discard_editor)
     nsapp = m.mock()
     ac.editors = eds = []
     all_settings = []
     for i in ed_config:
         ed = m.mock(Editor)
         eds.append(ed)
         ed.window_settings_loaded >> (i != 2)
         if i != 2:
             settings = "<settings %s>" % i
             all_settings.append(settings)
             ed.window_settings >> settings
     iter_editors(nsapp) >> reversed(eds)
     defaults = df_class.standardUserDefaults() >> MockUserDefaults()
     save_open_projects(defaults)
     with m:
         ac.app_will_terminate(nsapp)
     result = defaults.arrayForKey_(const.WINDOW_SETTINGS_DEFAULTS_KEY)
     eq_(result, all_settings)
     assert defaults.synced
开发者ID:youngrok,项目名称:editxt,代码行数:28,代码来源:test_application.py

示例6: test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def test(app, has_text_storage, event=None):
     INDENT_SIZE = 42
     m = Mocker()
     ps_class = m.replace(ak, 'NSParagraphStyle')
     doc = TextDocument(app)
     if has_text_storage:
         with m.off_the_record():
             ts = doc.text_storage = m.mock(ak.NSTextStorage)
     else:
         ts = doc.text_storage = None
     font = app.default_font.font
     tabw = ak.NSString.stringWithString_("8" * INDENT_SIZE) \
              .sizeWithAttributes_({ak.NSFontAttributeName: font}).width
     ps = ps_class.defaultParagraphStyle().mutableCopy() >> m.mock()
     ps.setTabStops_([])
     ps.setDefaultTabInterval_(tabw)
     attrs = {
         ak.NSFontAttributeName: font,
         ak.NSParagraphStyleAttributeName: ps,
         ak.NSForegroundColorAttributeName: app.theme.text_color,
     }
     if has_text_storage:
         no_color = {k: v for k, v in attrs.items()
                     if k != ak.NSForegroundColorAttributeName}
         ts.addAttributes_range_(no_color, fn.NSMakeRange(0, ts.length() >> 20))
         ts.setFont_(doc.font.font)
     editors = [m.mock(Editor), m.mock(Editor)]
     m.method(app.iter_editors_of_document)(doc) >> editors
     for editor in editors:
         editor.set_text_attributes(attrs)
     with m:
         doc.reset_text_attributes(INDENT_SIZE, event)
         eq_(doc.default_text_attributes(), attrs)
         eq_(doc.syntax_needs_color,
             has_text_storage and event and event.theme_changed)
开发者ID:editxt,项目名称:editxt,代码行数:37,代码来源:test_document.py

示例7: test_set_syntaxdef

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
def test_set_syntaxdef(app):
    from editxt.syntax import SyntaxDefinition
    m = Mocker()
    sd = m.mock(SyntaxDefinition)
    doc = TextDocument(app)
    m.method(doc.color_text)()
    with m:
        doc.syntaxdef = sd
        eq_(doc.syntaxer.syntaxdef, sd)
开发者ID:editxt,项目名称:editxt,代码行数:11,代码来源:test_document.py

示例8: test_SortLinesController_sort_

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
def test_SortLinesController_sort_():
    m = Mocker()
    sort = m.replace(sortlines, passthrough=False)
    tv = m.mock(TextView)
    slc = SortLinesController.create_with_textview(tv)
    sort(tv, slc.opts)
    m.method(slc.save_options)()
    m.method(slc.cancel_)(None)
    with m:
        slc.sort_(None)
开发者ID:youngrok,项目名称:editxt,代码行数:12,代码来源:test_sortlines.py

示例9: test_WrapLinesController_wrap_

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
def test_WrapLinesController_wrap_():
    m = Mocker()
    cmd = m.replace(mod, 'wrap_selected_lines')
    tv = m.mock(TextView)
    ctl = WrapLinesController(tv)
    cmd(tv, ctl.options)
    m.method(ctl.save_options)()
    m.method(ctl.cancel_)(None)
    with m:
        ctl.wrap_(None)
开发者ID:khairy,项目名称:editxt,代码行数:12,代码来源:test_wraplines.py

示例10: test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def test(c):
     m = Mocker()
     fc = FindController.shared_controller()
     sender = m.mock()
     if "do" in c:
         c.do(m, c, fc, sender)
     else:
         m.method(fc.finder, c.real)(*c.args)
     with m:
         getattr(fc, c.meth)(sender)
开发者ID:khairy,项目名称:editxt,代码行数:12,代码来源:test_find.py

示例11: test_init_with_serial

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
def test_init_with_serial():
    m = Mocker()
    kvo_class = m.replace(mod, 'KVOList')
    deserialize = m.method(Project.deserialize)
    reset_cache = m.method(Project.reset_serial_cache)
    docs = kvo_class.alloc().init() >> []
    deserialize("<serial>")
    reset_cache(); m.count(2)
    with m:
        proj = Project.alloc().init_with_serial("<serial>")
开发者ID:khairy,项目名称:editxt,代码行数:12,代码来源:test_project.py

示例12: test_SortLinesController_sort_

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
def test_SortLinesController_sort_():
    m = Mocker()
    sort = m.replace(mod, 'sortlines')
    tv = m.mock(TextView)
    with replace_history() as history:
        slc = SortLinesController(tv)
        sort(tv, slc.options)
        m.method(slc.save_options)()
        m.method(slc.cancel_)(None)
        with m:
            slc.sort_(None)
开发者ID:khairy,项目名称:editxt,代码行数:13,代码来源:test_sortlines.py

示例13: test_SortLinesController_sort_

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
def test_SortLinesController_sort_():
    m = Mocker()
    sort = m.replace(mod, 'sortlines')
    with test_app() as app:
        editor = base.Options(app=app)
        slc = SortLinesController(editor)
        sort(editor, slc.options)
        m.method(slc.save_options)()
        m.method(slc.cancel_)(None)
        with m:
            slc.sort_(None)
开发者ID:editxt,项目名称:editxt,代码行数:13,代码来源:test_sortlines.py

示例14: test_WrapLinesController_wrap_

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
def test_WrapLinesController_wrap_():
    with test_app() as app:
        m = Mocker()
        editor = base.Options(app=app)
        cmd = m.replace(mod, 'wrap_selected_lines')
        ctl = WrapLinesController(editor)
        cmd(editor, ctl.options)
        m.method(ctl.save_options)()
        m.method(ctl.cancel_)(None)
        with m:
            ctl.wrap_(None)
开发者ID:editxt,项目名称:editxt,代码行数:13,代码来源:test_wraplines.py

示例15: test

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import method [as 别名]
 def test(c):
     with test_app() as app:
         m = Mocker()
         fc = FindController(app)
         sender = m.mock()
         if "do" in c:
             c.do(m, c, fc, sender)
         else:
             m.method(fc.finder, c.real)(*c.args)
         with m:
             getattr(fc, c.meth)(sender)
开发者ID:editxt,项目名称:editxt,代码行数:13,代码来源:test_find.py


注:本文中的mocker.Mocker.method方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。