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


Python tools.assert_false方法代码示例

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


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

示例1: test_euler_instability

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_euler_instability():
    # Test for numerical errors in mat2euler
    # problems arise for cos(y) near 0
    po2 = pi / 2
    zyx = po2, po2, po2
    M = nea.euler2mat(*zyx)
    # Round trip
    M_back = nea.euler2mat(*nea.mat2euler(M))
    yield assert_true, np.allclose(M, M_back)
    # disturb matrix slightly
    M_e = M - FLOAT_EPS
    # round trip to test - OK
    M_e_back = nea.euler2mat(*nea.mat2euler(M_e))
    yield assert_true, np.allclose(M_e, M_e_back)
    # not so with crude routine
    M_e_back = nea.euler2mat(*crude_mat2euler(M_e))
    yield assert_false, np.allclose(M_e, M_e_back) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:19,代码来源:test_euler.py

示例2: test_sugar

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_sugar():
    # Syntactic sugar for recoder class
    codes = ((1,'one','1','first'), (2,'two'))
    rc = Recoder(codes)
    # Field1 is synonym for first named dict
    yield assert_equal, rc.code, rc.field1
    rc = Recoder(codes, fields=('code1', 'label'))
    yield assert_equal, rc.code1, rc.field1
    # Direct key access identical to key access for first named
    yield assert_equal, rc[1], rc.field1[1]
    yield assert_equal, rc['two'], rc.field1['two']
    # keys gets all keys
    yield assert_equal, set(rc.keys()), set((1,'one','1','first',2,'two'))
    # value_set gets set of values from first column
    yield assert_equal, rc.value_set(), set((1, 2))
    # or named column if given
    yield assert_equal, rc.value_set('label'), set(('one', 'two'))
    # "in" works for values in and outside the set
    yield assert_true, 'one' in rc
    yield assert_false, 'three' in rc 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:22,代码来源:test_recoder.py

示例3: test_finite_scheduler

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_finite_scheduler(self):
        def scheduler():
            yield 3
            yield 5
            yield 8

        tt = mm.Timer(scheduler(), self.callback, self.tag)
        tt.start()

        tt.join()

        nt.assert_false(tt.is_running)

        nt.assert_equal(
            self.callback.call_args_list,
            [
                mock.call(self.get_metrics.return_value),
                mock.call(self.get_metrics.return_value),
                mock.call(self.get_metrics.return_value),
            ]
        )

        nt.assert_equal(self.time.current_time, 10)
        nt.assert_equal(self.time.sleeps, [3, 1, 2]) 
开发者ID:avalente,项目名称:appmetrics,代码行数:26,代码来源:test_reporter.py

示例4: test_no_metrics

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_no_metrics(self):
        self.get_metrics.return_value = {}

        def scheduler():
            yield 3
            yield 5
            yield 8

        tt = mm.Timer(scheduler(), self.callback, self.tag)
        tt.start()

        tt.join()

        nt.assert_false(tt.is_running)

        nt.assert_equal(self.callback.call_count, 0)
        nt.assert_equal(self.time.sleeps, [3, 1, 2]) 
开发者ID:avalente,项目名称:appmetrics,代码行数:19,代码来源:test_reporter.py

示例5: test_handlers

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_handlers(self):
        f = StringIO()
        hdlr = gogo.handlers.fileobj_hdlr(f)
        lggr = gogo.Gogo("test_handlers", high_hdlr=hdlr).logger

        msg1 = "stdout hdlr only"
        lggr.debug(msg1)
        f.seek(0)
        nt.assert_equal(msg1, sys.stdout.getvalue().strip())
        nt.assert_false(f.read())

        msg2 = "both hdlrs"
        lggr.error(msg2)
        f.seek(0)
        nt.assert_equal("%s\n%s" % (msg1, msg2), sys.stdout.getvalue().strip())
        nt.assert_equal(f.read().strip(), msg2) 
开发者ID:reubano,项目名称:pygogo,代码行数:18,代码来源:test_main.py

示例6: test_upgrade_from_sha_with_unicode_password

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_upgrade_from_sha_with_unicode_password(self):
        user = factories.User()
        password = u'testpassword\xc2\xa0'
        user_obj = model.User.by_name(user['name'])

        # setup our user with an old password hash
        old_hash = self._set_password(password)
        user_obj._password = old_hash
        user_obj.save()

        nt.assert_true(user_obj.validate_password(password))
        nt.assert_not_equals(old_hash, user_obj.password)
        nt.assert_true(pbkdf2_sha512.identify(user_obj.password))
        nt.assert_true(pbkdf2_sha512.verify(password, user_obj.password))

        # check that we now allow unicode characters
        nt.assert_false(pbkdf2_sha512.verify('testpassword',
                                             user_obj.password)) 
开发者ID:italia,项目名称:daf-recipes,代码行数:20,代码来源:test_user.py

示例7: test_deepreload

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_deepreload():
    "Test that dreload does deep reloads and skips excluded modules."
    with TemporaryDirectory() as tmpdir:
        with prepended_to_syspath(tmpdir):
            with open(os.path.join(tmpdir, 'A.py'), 'w') as f:
                f.write("class Object(object):\n    pass\n")
            with open(os.path.join(tmpdir, 'B.py'), 'w') as f:
                f.write("import A\n")
            import A
            import B

            # Test that A is not reloaded.
            obj = A.Object()
            dreload(B, exclude=['A'])
            nt.assert_true(isinstance(obj, A.Object))

            # Test that A is reloaded.
            obj = A.Object()
            dreload(B)
            nt.assert_false(isinstance(obj, A.Object)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:test_deepreload.py

示例8: test_command_chain_dispatcher_fofo

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_command_chain_dispatcher_fofo():
    """Test a mixture of failing and succeeding hooks."""
    fail1 = Fail(u'fail1')
    fail2 = Fail(u'fail2')
    okay1 = Okay(u'okay1')
    okay2 = Okay(u'okay2')

    dp = CommandChainDispatcher([(0, fail1),
                                 # (5, okay1), # add this later
                                 (10, fail2),
                                 (15, okay2)])
    dp.add(okay1, 5)

    nt.assert_equal(dp(), u'okay1')

    nt.assert_true(fail1.called)
    nt.assert_true(okay1.called)
    nt.assert_false(fail2.called)
    nt.assert_false(okay2.called) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:test_hooks.py

示例9: test_omit__names

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_omit__names():
    # also happens to test IPCompleter as a configurable
    ip = get_ipython()
    ip._hidden_attr = 1
    c = ip.Completer
    ip.ex('ip=get_ipython()')
    cfg = Config()
    cfg.IPCompleter.omit__names = 0
    c.update_config(cfg)
    s,matches = c.complete('ip.')
    nt.assert_true('ip.__str__' in matches)
    nt.assert_true('ip._hidden_attr' in matches)
    cfg.IPCompleter.omit__names = 1
    c.update_config(cfg)
    s,matches = c.complete('ip.')
    nt.assert_false('ip.__str__' in matches)
    nt.assert_true('ip._hidden_attr' in matches)
    cfg.IPCompleter.omit__names = 2
    c.update_config(cfg)
    s,matches = c.complete('ip.')
    nt.assert_false('ip.__str__' in matches)
    nt.assert_false('ip._hidden_attr' in matches)
    del ip._hidden_attr 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:test_completer.py

示例10: test_check_state1

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_check_state1(app1, job_id1, job_id2):

    nt.assert_false(api.check_state(app1, 'doesnotexist', pending=True))
    with nt.assert_raises(NoNodeError):
        api.check_state(app1, 'doesnotexist', raise_if_not_exists=True)

    qb.set_state(app1, job_id1, pending=True)
    # also: create an invalid state (one that stolos does not recognize)
    api.get_qbclient().create(
        qb.get_job_path(app1, job_id2), '')

    with nt.assert_raises(UserWarning):
        api.check_state(app1, job_id1)
    nt.assert_true(
        api.check_state(app1, job_id1, pending=True))
    nt.assert_true(
        api.check_state(app1, job_id1, pending=True, completed=True))
    nt.assert_false(api.check_state(app1, job_id1, completed=True))
    nt.assert_true(api.check_state(app1, job_id1, all=True))
    # the invalid job:
    nt.assert_false(api.check_state(app1, job_id2, all=True)) 
开发者ID:sailthru,项目名称:stolos,代码行数:23,代码来源:test_api.py

示例11: test_Lock1

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_Lock1(qbcli, app1):
    lock = qbcli.Lock(app1)
    nt.assert_false(qbcli.exists(app1))

    lock2 = qbcli.Lock(app1)
    nt.assert_not_equal(lock, lock2)

    # acquire lock 1st time
    nt.assert_true(lock.acquire(blocking=True, timeout=1))

    # should not hang
    nt.assert_false(lock2.acquire())
    # should timeout
    # TODO: with nt.assert_raises(exceptions.Timeout):
    nt.assert_false(lock2.acquire(blocking=True, timeout=1))

    with nt.assert_raises(UserWarning):
        lock2.release()
    lock.release()
    nt.assert_true(lock2.acquire())
    lock2.release() 
开发者ID:sailthru,项目名称:stolos,代码行数:23,代码来源:test_return_values.py

示例12: test_LockingQueue_size

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_LockingQueue_size(qbcli, app1, item1, item2):
    nt.assert_false(qbcli.exists(app1))
    queue = qbcli.LockingQueue(app1)
    with nt.assert_raises(AttributeError):
        queue.size(taken=False, queued=False)

    nt.assert_equal(queue.size(), 0)
    nt.assert_equal(queue.size(taken=True, queued=False), 0)
    nt.assert_equal(queue.size(taken=False, queued=True), 0)
    queue.put(item1)
    nt.assert_equal(queue.size(), 1)
    queue.put(item2)
    queue.put(item1)
    nt.assert_equal(queue.size(), 3)
    nt.assert_equal(queue.size(taken=True, queued=True), 3)

    # test various parameters of queue.size
    nt.assert_equal(queue.get(), item1)
    nt.assert_equal(queue.size(taken=True, queued=False), 1)
    nt.assert_equal(queue.size(queued=False), 1)
    nt.assert_equal(queue.size(taken=False, queued=True), 2)
    nt.assert_equal(queue.size(taken=False), 2)
    # cleanup
    queue.consume() 
开发者ID:sailthru,项目名称:stolos,代码行数:26,代码来源:test_return_values.py

示例13: test_read_write_files

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_read_write_files():
    # test round trip for example file
    cwd = os.getcwd()
    try:
        tmpdir = tempfile.mkdtemp()
        os.chdir(tmpdir)
        f = make_simple('simple.nc', 'w')
        f.close()
        # To read the NetCDF file we just created::
        f = netcdf_file('simple.nc')
        # Using mmap is the default
        yield assert_true, f.use_mmap
        for testargs in gen_for_simple(f):
            yield testargs
        f.close()
        # Now without mmap
        f = netcdf_file('simple.nc', mmap=False)
        # Using mmap is the default
        yield assert_false, f.use_mmap
        for testargs in gen_for_simple(f):
            yield testargs
        f.close()
        # To read the NetCDF file we just created, as file object, no
        # mmap.  When n * n_bytes(var_type) is not divisible by 4, this
        # raised an error in pupynere 1.0.12 and scipy rev 5893, because
        # calculated vsize was rounding up in units of 4 - see
        # http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html
        fobj = open('simple.nc', 'rb')
        f = netcdf_file(fobj)
        # by default, don't use mmap for file-like
        yield assert_false, f.use_mmap
        for testargs in gen_for_simple(f):
            yield testargs
        f.close()
    except:
        os.chdir(cwd)
        shutil.rmtree(tmpdir)
        raise
    os.chdir(cwd)
    shutil.rmtree(tmpdir) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:42,代码来源:test_netcdf.py

示例14: test_infinite_scheduler

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_infinite_scheduler(self):
        tt = mm.Timer(mm.fixed_interval_scheduler(10), self.callback, self.tag)

        # trick: when the time is >= 1000 call tt.cancel(), else it would run forever
        self.callback.side_effect = lambda x: None if self.time.current_time < 1000 else tt.cancel()

        tt.start()

        tt.join()

        nt.assert_false(tt.is_running)
        # one run every 10 seconds, for 1000 seconds total
        nt.assert_equal(self.callback.call_count, 1000/10)

        nt.assert_equal(self.time.sleeps, [11, 8] + [9]*98) 
开发者ID:avalente,项目名称:appmetrics,代码行数:17,代码来源:test_reporter.py

示例15: test_same_kind_with_different_class

# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_false [as 别名]
def test_same_kind_with_different_class(self):
        other = mm.SlidingWindowReservoir(self.ur.size)
        nt.assert_false(self.ur.same_kind(other)) 
开发者ID:avalente,项目名称:appmetrics,代码行数:5,代码来源:test_histogram.py


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