當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。