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


Python tools.assert_not_in方法代码示例

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


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

示例1: test_autorestore

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_autorestore():
    ip.user_ns['foo'] = 95
    ip.magic('store foo')
    del ip.user_ns['foo']
    c = Config()
    c.StoreMagics.autorestore = False
    orig_config = ip.config
    try:
        ip.config = c
        ip.extension_manager.reload_extension('storemagic')
        nt.assert_not_in('foo', ip.user_ns)
        c.StoreMagics.autorestore = True
        ip.extension_manager.reload_extension('storemagic')
        nt.assert_equal(ip.user_ns['foo'], 95)
    finally:
        ip.config = orig_config 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:test_storemagic.py

示例2: test_ipython_start_kernel_no_userns

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_ipython_start_kernel_no_userns():
    # Issue #4188 - user_ns should be passed to shell as None, not {}
    cmd = ('from IPython import start_kernel\n'
           'start_kernel()')

    with setup_kernel(cmd) as client:
        # user_module should not be an instance of DummyMod
        msg_id = client.execute("usermod = get_ipython().user_module")
        msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
        content = msg['content']
        nt.assert_equal(content['status'], u'ok')
        msg_id = client.object_info('usermod')
        msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
        content = msg['content']
        assert content['found']
        nt.assert_not_in('DummyMod', content['string_form']) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:test_start_kernel.py

示例3: test_line_cell_magics

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_line_cell_magics():
    from IPython.core.magic import register_line_cell_magic

    @register_line_cell_magic
    def _bar_cellm(line, cell):
        pass
    
    ip = get_ipython()
    c = ip.Completer

    # The policy here is trickier, see comments in completion code.  The
    # returned values depend on whether the user passes %% or not explicitly,
    # and this will show a difference if the same name is both a line and cell
    # magic.
    s, matches = c.complete(None, '_bar_ce')
    nt.assert_in('%_bar_cellm', matches)
    nt.assert_in('%%_bar_cellm', matches)
    s, matches = c.complete(None, '%_bar_ce')
    nt.assert_in('%_bar_cellm', matches)
    nt.assert_in('%%_bar_cellm', matches)
    s, matches = c.complete(None, '%%_bar_ce')
    nt.assert_not_in('%_bar_cellm', matches)
    nt.assert_in('%%_bar_cellm', matches) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:test_completer.py

示例4: test_rehashx

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_rehashx():
    # clear up everything
    _ip = get_ipython()
    _ip.alias_manager.alias_table.clear()
    del _ip.db['syscmdlist']
    
    _ip.magic('rehashx')
    # Practically ALL ipython development systems will have more than 10 aliases

    nt.assert_true(len(_ip.alias_manager.alias_table) > 10)
    for key, val in _ip.alias_manager.alias_table.iteritems():
        # we must strip dots from alias names
        nt.assert_not_in('.', key)

    # rehashx must fill up syscmdlist
    scoms = _ip.db['syscmdlist']
    nt.assert_true(len(scoms) > 10) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:test_magic.py

示例5: test_alias_magic

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_alias_magic():
    """Test %alias_magic."""
    ip = get_ipython()
    mm = ip.magics_manager

    # Basic operation: both cell and line magics are created, if possible.
    ip.run_line_magic('alias_magic', 'timeit_alias timeit')
    nt.assert_in('timeit_alias', mm.magics['line'])
    nt.assert_in('timeit_alias', mm.magics['cell'])

    # --cell is specified, line magic not created.
    ip.run_line_magic('alias_magic', '--cell timeit_cell_alias timeit')
    nt.assert_not_in('timeit_cell_alias', mm.magics['line'])
    nt.assert_in('timeit_cell_alias', mm.magics['cell'])

    # Test that line alias is created successfully.
    ip.run_line_magic('alias_magic', '--line env_alias env')
    nt.assert_equal(ip.run_line_magic('env', ''),
                    ip.run_line_magic('env_alias', '')) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:test_magic.py

示例6: test_remove

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_remove(self):
        m1 = mock.Mock()
        mm.REGISTRY = {'m1': m1, 'm2': mock.Mock()}

        nt.assert_is(mm.remove('m1'), m1)

        nt.assert_not_in('m1', mm.REGISTRY)
        nt.assert_equal(
            m1.cancel.call_args_list,
            [mock.call()]) 
开发者ID:avalente,项目名称:appmetrics,代码行数:12,代码来源:test_reporter.py

示例7: test_debugging

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_debugging(self):
        console_msg = (
            "This should log\nSo should this\nAnd this too\nThis should log "
            "also\nSo should this\nAnd this too\nBut this one should\nAnd this"
            " one too"
        )

        logger = gogo.Gogo("debug.none").logger
        logger.debug("This should log")
        logger.info("So should this")
        logger.warning("And this too")

        logger = gogo.Gogo("debug.on", verbose=True).logger
        logger.debug("This should log also")
        logger.info("So should this")
        logger.warning("And this too")

        logger = gogo.Gogo("debug.off", verbose=False).logger
        logger.debug("This shouldn't log")
        logger.info("But this one should")
        logger.warning("And this one too")

        results = sys.stdout.getvalue().strip()
        nt.assert_in("This should log", results)
        nt.assert_not_in("This shouldn't log", results)
        nt.assert_equal(console_msg, results) 
开发者ID:reubano,项目名称:pygogo,代码行数:28,代码来源:test_main.py

示例8: help_output_test

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def help_output_test(subcommand=''):
    """test that `ipython [subcommand] -h` works"""
    cmd = ' '.join(get_ipython_cmd() + [subcommand, '-h'])
    out, err, rc = get_output_error_code(cmd)
    nt.assert_equal(rc, 0, err)
    nt.assert_not_in("Traceback", err)
    nt.assert_in("Options", out)
    nt.assert_in("--help-all", out)
    return out, err 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:tools.py

示例9: help_all_output_test

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def help_all_output_test(subcommand=''):
    """test that `ipython [subcommand] --help-all` works"""
    cmd = ' '.join(get_ipython_cmd() + [subcommand, '--help-all'])
    out, err, rc = get_output_error_code(cmd)
    nt.assert_equal(rc, 0, err)
    nt.assert_not_in("Traceback", err)
    nt.assert_in("Options", out)
    nt.assert_in("Class parameters", out)
    return out, err 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:tools.py

示例10: assert_not_in

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def assert_not_in(item, collection):
    assert item not in collection, '%r in %r' % (item, collection) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:nose_assert_methods.py

示例11: test_numpy_reset_array_undec

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_numpy_reset_array_undec():
    "Test '%reset array' functionality"
    _ip.ex('import numpy as np')
    _ip.ex('a = np.empty(2)')
    nt.assert_in('a', _ip.user_ns)
    _ip.magic('reset -f array')
    nt.assert_not_in('a', _ip.user_ns) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_magic.py

示例12: test_rich_text_editor_is_not_shown_when_not_configured

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_rich_text_editor_is_not_shown_when_not_configured(self):
        app = self._get_test_app()
        sysadmin = factories.Sysadmin()
        factories.Dataset(name='my-showcase', type='showcase')

        env = {'REMOTE_USER': sysadmin['name'].encode('ascii')}
        response = app.get(
            url=url_for(controller='ckanext.showcase.controller:ShowcaseController',
                        action='edit',
                        id='my-showcase'),
            extra_environ=env,
        )
        nosetools.assert_not_in('<textarea id="editor"', response.ubody) 
开发者ID:ckan,项目名称:ckanext-showcase,代码行数:15,代码来源:test_plugin.py

示例13: test_structured_logging

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_not_in [as 别名]
def test_structured_logging(self):
        kwargs = {"persist": True}
        extra = {"additional": True}
        meta = set(["level", "name", "time"])

        # Basic structured logger
        logger0 = gogo.Gogo("logger0").get_structured_logger("base", **kwargs)

        # Structured formatter
        formatter = gogo.formatters.structured_formatter
        logger1 = gogo.Gogo("logger1", low_formatter=formatter).logger

        # JSON formatter
        formatter = gogo.formatters.json_formatter
        logger2 = gogo.Gogo("logger2", low_formatter=formatter).logger

        # Custom logger
        logfmt = (
            '{"time": "%(asctime)s.%(msecs)d", "name": "%(name)s", "level":'
            ' "%(levelname)s", "message": "%(message)s", '
            '"persist": "%(persist)s", "additional": "%(additional)s"}'
        )

        fmtr = logging.Formatter(logfmt, datefmt=gogo.formatters.DATEFMT)
        logger3 = gogo.Gogo("logger3", low_formatter=fmtr).get_logger(**kwargs)

        # Now log some messages
        for logger in [logger0, logger1, logger2, logger3]:
            logger.debug("message", extra=extra)

        lines = sys.stdout.getvalue().strip().split("\n")
        results = [loads(l) for l in lines]

        # Assert the following loggers provide the log event meta data
        nt.assert_is_not_subset(meta, results[0])
        nt.assert_is_subset(meta, results[1])
        nt.assert_is_subset(meta, results[2])
        nt.assert_is_subset(meta, results[3])

        # Assert the following loggers provide the `extra` information
        nt.assert_in("additional", results[0])
        nt.assert_in("additional", results[1])
        nt.assert_not_in("additional", results[2])
        nt.assert_in("additional", results[3])

        # Assert the following loggers provide the `persist` information
        nt.assert_in("persist", results[0])
        nt.assert_in("persist", results[1])
        nt.assert_not_in("persist", results[2])
        nt.assert_in("persist", results[3])

        # Assert the following loggers provide the `msecs` in the time
        nt.assert_false(len(results[0].get("time", [])))
        nt.assert_false(len(results[1]["time"][20:]))
        nt.ok_(len(results[2]["time"][20:]))
        nt.ok_(len(results[3]["time"][20:])) 
开发者ID:reubano,项目名称:pygogo,代码行数:58,代码来源:test_main.py


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