• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tools.assert_false函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_fetch_stored_values_fixed

 def test_fetch_stored_values_fixed(self):
     c = self.c
     c.one.fetch = mock.MagicMock()
     c.two.fetch = mock.MagicMock()
     c.fetch_stored_values(only_fixed=True)
     nt.assert_true(c.one.fetch.called)
     nt.assert_false(c.two.fetch.called)
开发者ID:AakashV,项目名称:hyperspy,代码行数:7,代码来源:test_component.py


示例2: test_get_courses_has_no_templates

 def test_get_courses_has_no_templates(self):
     courses = self.store.get_courses()
     for course in courses:
         assert_false(
             course.location.org == 'edx' and course.location.course == 'templates',
             '{0} is a template course'.format(course)
         )
开发者ID:Fyre91,项目名称:edx-platform,代码行数:7,代码来源:test_mongo.py


示例3: test_incremental

 def test_incremental(self):
     sp = self.sp
     sp.push('%%cellm line2\n')
     nt.assert_true(sp.push_accepts_more()) #1
     sp.push('\n')
     # In this case, a blank line should end the cell magic
     nt.assert_false(sp.push_accepts_more()) #2
开发者ID:marcosptf,项目名称:fedora,代码行数:7,代码来源:test_inputsplitter.py


示例4: test_add_etcd_down

    def test_add_etcd_down(self):
        """
        Tests CNI add, etcd is not running when we attempt to get 
        an Endpoint from etcd.
        """
        # Configure.
        self.command = CNI_CMD_ADD
        ip4 = "10.0.0.1/32"
        ip6 = "0:0:0:0:0:ffff:a00:1"
        ipam_stdout = json.dumps({"ip4": {"ip": ip4}, 
                                  "ip6": {"ip": ip6}})
        self.set_ipam_result(0, ipam_stdout, "")

        # Mock out get_endpoint to raise DataStoreError.
        self.client.get_endpoint.side_effect = DataStoreError

        # Create plugin.
        p = self.create_plugin()

        # Execute.
        with assert_raises(SystemExit) as err:
            p.execute()
        e = err.exception

        # Assert failure.
        assert_equal(e.code, ERR_CODE_GENERIC)
        
        # Assert an endpoint was not created.
        assert_false(self.client.create_endpoint.called) 

        # Assert a profile was not set.
        assert_false(self.client.append_profiles_to_endpoint.called)
开发者ID:MikeSpreitzer,项目名称:calico-cni,代码行数:32,代码来源:test_calico_cni.py


示例5: test_data_scaling

 def test_data_scaling(self):
     hdr = self.header_class()
     hdr.set_data_shape((1,2,3))
     hdr.set_data_dtype(np.int16)
     S3 = BytesIO()
     data = np.arange(6, dtype=np.float64).reshape((1,2,3))
     # This uses scaling
     hdr.data_to_fileobj(data, S3)
     data_back = hdr.data_from_fileobj(S3)
     # almost equal
     assert_array_almost_equal(data, data_back, 4)
     # But not quite
     assert_false(np.all(data == data_back))
     # This is exactly the same call, just testing it works twice
     data_back2 = hdr.data_from_fileobj(S3)
     assert_array_equal(data_back, data_back2, 4)
     # Rescaling is the default
     hdr.data_to_fileobj(data, S3, rescale=True)
     data_back = hdr.data_from_fileobj(S3)
     assert_array_almost_equal(data, data_back, 4)
     assert_false(np.all(data == data_back))
     # This doesn't use scaling, and so gets perfect precision
     hdr.data_to_fileobj(data, S3, rescale=False)
     data_back = hdr.data_from_fileobj(S3)
     assert_true(np.all(data == data_back))
开发者ID:adykstra,项目名称:nibabel,代码行数:25,代码来源:test_spm99analyze.py


示例6: test_pickler_proxy

def test_pickler_proxy():
    h = Hist(5, 0, 1, name='hist')
    f = tempfile.NamedTemporaryFile(suffix='.root')

    with root_open(f.name, 'recreate') as outfile:
        dump([h], outfile)

    class IsCalled(object):
        def __init__(self, func):
            self.func = func
            self.called = False

        def __call__(self, path):
            if path != '_pickle;1':
                self.called = True
            return self.func(path)

    with root_open(f.name) as infile:
        infile.Get = IsCalled(infile.Get)
        hlist = load(infile, use_proxy=False)
        assert_true(infile.Get.called)

    with root_open(f.name) as infile:
        infile.Get = IsCalled(infile.Get)
        hlist = load(infile, use_proxy=True)
        assert_false(infile.Get.called)
        assert_equal(hlist[0].name, 'hist')
        assert_true(infile.Get.called)

    f.close()
开发者ID:edwardjrhodes,项目名称:rootpy,代码行数:30,代码来源:test_pickler.py


示例7: test_add_ipam_error

    def test_add_ipam_error(self):
        """
        Tests CNI add, IPAM plugin fails. 

        The plugin should return an error code and print the IPAM result,
        but should not need to clean anything up since IPAM is the first
        step in CNI add.
        """
        # Configure.
        self.command = CNI_CMD_ADD
        ip4 = "10.0.0.1/32"
        ip6 = "0:0:0:0:0:ffff:a00:1"
        ipam_stdout = json.dumps({"code": 100, "msg": "Test IPAM error"})
        self.set_ipam_result(100, ipam_stdout, "")

        # Mock DatastoreClient such that no endpoints exist.
        self.client.get_endpoint.side_effect = KeyError

        # Create plugin.
        p = self.create_plugin()

        # Execute.
        with assert_raises(SystemExit) as err:
            p.execute()
        e = err.exception

        # Assert success.
        assert_equal(e.code, ERR_CODE_GENERIC)
        
        # Assert an endpoint was not created.
        assert_false(self.client.create_endpoint.called) 
开发者ID:MikeSpreitzer,项目名称:calico-cni,代码行数:31,代码来源:test_calico_cni.py


示例8: test_check1

 def test_check1(self):
     # Test everything is ok if folder and filename are correct.
     test, traceback = self.task.check()
     assert_true(test)
     assert_false(traceback)
     array = self.task.get_from_database('Test_array')
     assert_equal(array.dtype.names, ('Freq', 'Log'))
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:7,代码来源:test_load_tasks.py


示例9: test_check2

 def test_check2(self):
     # Test handling wrong folder and filename.
     self.task.folder = '{rr}'
     self.task.filename = '{tt}'
     test, traceback = self.task.check()
     assert_false(test)
     assert_equal(len(traceback), 2)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:7,代码来源:test_load_tasks.py


示例10: test_collectios_list

    def test_collectios_list(self):
        c = self.conn

        logger.info("Creationg three collections sample[1..3]")
        c.collection.sample1.create()
        c.collection.sample2.create()
        c.collection.sample3.create()

        logger.info("Getting list of collections")
        names = c.collection()

        for n in ["sample1", "sample2", "sample3"]:
            assert_true(n in names)

        logger.info("Deleting two of three collections")
        c.collection.sample1.delete()
        c.collection.sample3.delete()

        names = c.collection()

        for n in ["sample1", "sample3"]:
            assert_false(n in names)

        assert_true("sample2" in names)

        logger.info("Removing last collection")
        c.collection.sample2.delete()
开发者ID:aniljava,项目名称:arango-python,代码行数:27,代码来源:tests_collection_integration.py


示例11: test_useradmin_ldap_integration

def test_useradmin_ldap_integration():
    reset_all_users()
    reset_all_groups()

    # Set up LDAP tests to use a LdapTestConnection instead of an actual LDAP connection
    ldap_access.CACHED_LDAP_CONN = LdapTestConnection()

    # Try importing a user
    import_ldap_user("larry", import_by_dn=False)
    larry = User.objects.get(username="larry")
    assert_true(larry.first_name == "Larry")
    assert_true(larry.last_name == "Stooge")
    assert_true(larry.email == "[email protected]")
    assert_true(get_profile(larry).creation_method == str(UserProfile.CreationMethod.EXTERNAL))

    # Should be a noop
    sync_ldap_users()
    sync_ldap_groups()
    assert_equal(len(User.objects.all()), 1)
    assert_equal(len(Group.objects.all()), 0)

    # Should import a group, but will only sync already-imported members
    import_ldap_group("Test Administrators", import_members=False, import_by_dn=False)
    assert_equal(len(User.objects.all()), 1)
    assert_equal(len(Group.objects.all()), 1)
    test_admins = Group.objects.get(name="Test Administrators")
    assert_equal(len(test_admins.user_set.all()), 1)
    assert_equal(test_admins.user_set.all()[0].username, larry.username)

    # Import all members of TestUsers
    import_ldap_group("TestUsers", import_members=True, import_by_dn=False)
    test_users = Group.objects.get(name="TestUsers")
    assert_true(LdapGroup.objects.filter(group=test_users).exists())
    assert_equal(len(test_users.user_set.all()), 3)

    ldap_access.CACHED_LDAP_CONN.remove_user_group_for_test("moe", "TestUsers")
    import_ldap_group("TestUsers", import_members=False, import_by_dn=False)
    assert_equal(len(test_users.user_set.all()), 2)
    assert_equal(len(User.objects.get(username="moe").groups.all()), 0)

    ldap_access.CACHED_LDAP_CONN.add_user_group_for_test("moe", "TestUsers")
    import_ldap_group("TestUsers", import_members=False, import_by_dn=False)
    assert_equal(len(test_users.user_set.all()), 3)
    assert_equal(len(User.objects.get(username="moe").groups.all()), 1)

    # Make sure that if a Hue user already exists with a naming collision, we
    # won't overwrite any of that user's information.
    hue_user = User.objects.create(username="otherguy", first_name="Different", last_name="Guy")
    import_ldap_user("otherguy", import_by_dn=False)
    hue_user = User.objects.get(username="otherguy")
    assert_equal(get_profile(hue_user).creation_method, str(UserProfile.CreationMethod.HUE))
    assert_equal(hue_user.first_name, "Different")

    # Make sure Hue groups with naming collisions don't get marked as LDAP groups
    hue_group = Group.objects.create(name="OtherGroup")
    hue_group.user_set.add(hue_user)
    hue_group.save()
    import_ldap_group("OtherGroup", import_members=False, import_by_dn=False)
    assert_false(LdapGroup.objects.filter(group=hue_group).exists())
    assert_true(hue_group.user_set.filter(username=hue_user.username).exists())
开发者ID:kthguru,项目名称:hue,代码行数:60,代码来源:tests.py


示例12: test_dataverse_root_not_published

    def test_dataverse_root_not_published(self, mock_files, mock_connection, mock_text):
        mock_connection.return_value = create_mock_connection()
        mock_files.return_value = []
        mock_text.return_value = 'Do you want to publish?'

        self.project.set_privacy('public')
        self.project.save()

        alias = self.node_settings.dataverse_alias
        doi = self.node_settings.dataset_doi
        external_account = create_external_account()
        self.user.external_accounts.add(external_account)
        self.user.save()
        self.node_settings.set_auth(external_account, self.user)
        self.node_settings.dataverse_alias = alias
        self.node_settings.dataset_doi = doi
        self.node_settings.save()

        url = api_url_for('dataverse_root_folder',
                          pid=self.project._primary_key)

        # Contributor gets draft, no options
        res = self.app.get(url, auth=self.user.auth)
        assert_true(res.json[0]['permissions']['edit'])
        assert_false(res.json[0]['hasPublishedFiles'])
        assert_equal(res.json[0]['version'], 'latest')

        # Non-contributor gets nothing
        user2 = AuthUserFactory()
        res = self.app.get(url, auth=user2.auth)
        assert_equal(res.json, [])
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:31,代码来源:test_views.py


示例13: test_estimable

def test_estimable():
    rng = np.random.RandomState(20120713)
    N, P = (40, 10)
    X = rng.normal(size=(N, P))
    C = rng.normal(size=(1, P))
    isestimable = tools.isestimable
    assert_true(isestimable(C, X))
    assert_true(isestimable(np.eye(P), X))
    for row in np.eye(P):
        assert_true(isestimable(row, X))
    X = np.ones((40, 2))
    assert_true(isestimable([1, 1], X))
    assert_false(isestimable([1, 0], X))
    assert_false(isestimable([0, 1], X))
    assert_false(isestimable(np.eye(2), X))
    halfX = rng.normal(size=(N, 5))
    X = np.hstack([halfX, halfX])
    assert_false(isestimable(np.hstack([np.eye(5), np.zeros((5, 5))]), X))
    assert_false(isestimable(np.hstack([np.zeros((5, 5)), np.eye(5)]), X))
    assert_true(isestimable(np.hstack([np.eye(5), np.eye(5)]), X))
    # Test array-like for design
    XL = X.tolist()
    assert_true(isestimable(np.hstack([np.eye(5), np.eye(5)]), XL))
    # Test ValueError for incorrect number of columns
    X = rng.normal(size=(N, 5))
    for n in range(1, 4):
        assert_raises(ValueError, isestimable, np.ones((n,)), X)
    assert_raises(ValueError, isestimable, np.eye(4), X)
开发者ID:nsolcampbell,项目名称:statsmodels,代码行数:28,代码来源:test_tools.py


示例14: test_disable_pixel_switching_current_off

 def test_disable_pixel_switching_current_off(self):
     c = self.c
     c._axes_manager.indices = (1, 1)
     c.active = False
     c.active_is_multidimensional = True
     c.active_is_multidimensional = False
     nt.assert_false(c.active)
开发者ID:AakashV,项目名称:hyperspy,代码行数:7,代码来源:test_component.py


示例15: test_versions

def test_versions():
    fake_name = '_a_fake_package'
    fake_pkg = types.ModuleType(fake_name)
    assert_false('fake_pkg' in sys.modules)
    # Not inserted yet
    assert_bad(fake_name)
    try:
        sys.modules[fake_name] = fake_pkg
        # No __version__ yet
        assert_good(fake_name)  # With no version check
        assert_bad(fake_name, '1.0')
        # We can make an arbitrary callable to check version
        assert_good(fake_name, lambda pkg: True)
        # Now add a version
        fake_pkg.__version__ = '2.0'
        # We have fake_pkg > 1.0
        for min_ver in (None, '1.0', LooseVersion('1.0'), lambda pkg: True):
            assert_good(fake_name, min_ver)
        # We never have fake_pkg > 100.0
        for min_ver in ('100.0', LooseVersion('100.0'), lambda pkg: False):
            assert_bad(fake_name, min_ver)
        # Check error string for bad version
        pkg, _, _ = optional_package(fake_name, min_version='3.0')
        try:
            pkg.some_method
        except TripWireError as err:
            assert_equal(str(err),
                         'These functions need _a_fake_package version >= 3.0')
    finally:
        del sys.modules[fake_name]
开发者ID:GuillaumeTh,项目名称:nibabel,代码行数:30,代码来源:test_optpkg.py


示例16: test_ensure_home_directory_sync_ldap_users_groups

def test_ensure_home_directory_sync_ldap_users_groups():
  URL = reverse(sync_ldap_users_groups)

  reset_all_users()
  reset_all_groups()

  # Set up LDAP tests to use a LdapTestConnection instead of an actual LDAP connection
  ldap_access.CACHED_LDAP_CONN = LdapTestConnection()

  cluster = pseudo_hdfs4.shared_cluster()
  c = make_logged_in_client(cluster.superuser, is_superuser=True)
  cluster.fs.setuser(cluster.superuser)

  reset = []

  # Set to nonsensical value just to force new config usage.
  # Should continue to use cached connection.
  reset.append(desktop.conf.LDAP.LDAP_SERVERS.set_for_testing(get_nonsense_config()))

  try:
    c.post(reverse(add_ldap_users), dict(server='nonsense', username_pattern='curly', password1='test', password2='test'))
    assert_false(cluster.fs.exists('/user/curly'))
    assert_true(c.post(URL, dict(server='nonsense', ensure_home_directory=True)))
    assert_true(cluster.fs.exists('/user/curly'))
  finally:
    for finish in reset:
      finish()

    if cluster.fs.exists('/user/curly'):
      cluster.fs.rmtree('/user/curly')
开发者ID:neiodavince,项目名称:hue,代码行数:30,代码来源:test_ldap.py


示例17: test_space_net_alpha_grid_pure_spatial

def test_space_net_alpha_grid_pure_spatial():
    rng = check_random_state(42)
    X = rng.randn(10, 100)
    y = np.arange(X.shape[0])
    for is_classif in [True, False]:
        assert_false(np.any(np.isnan(_space_net_alpha_grid(
            X, y, l1_ratio=0., logistic=is_classif))))
开发者ID:CandyPythonFlow,项目名称:nilearn,代码行数:7,代码来源:test_space_net.py


示例18: test_finite_range_nan

def test_finite_range_nan():
    # Test finite range method and has_nan property
    for in_arr, res in (
        ([[-1, 0, 1],[np.inf, np.nan, -np.inf]], (-1, 1)),
        (np.array([[-1, 0, 1],[np.inf, np.nan, -np.inf]]), (-1, 1)),
        ([[np.nan],[np.nan]], (np.inf, -np.inf)), # all nans slices
        (np.zeros((3, 4, 5)) + np.nan, (np.inf, -np.inf)),
        ([[-np.inf],[np.inf]], (np.inf, -np.inf)), # all infs slices
        (np.zeros((3, 4, 5)) + np.inf, (np.inf, -np.inf)),
        ([[np.nan, -1, 2], [-2, np.nan, 1]], (-2, 2)),
        ([[np.nan, -np.inf, 2], [-2, np.nan, np.inf]], (-2, 2)),
        ([[-np.inf, 2], [np.nan, 1]], (1, 2)), # good max case
        ([[np.nan, -np.inf, 2], [-2, np.nan, np.inf]], (-2, 2)),
        ([np.nan], (np.inf, -np.inf)),
        ([np.inf], (np.inf, -np.inf)),
        ([-np.inf], (np.inf, -np.inf)),
        ([np.inf, 1], (1, 1)), # only look at finite values
        ([-np.inf, 1], (1, 1)),
        ([[],[]], (np.inf, -np.inf)), # empty array
        (np.array([[-3, 0, 1], [2, -1, 4]], dtype=np.int), (-3, 4)),
        (np.array([[1, 0, 1], [2, 3, 4]], dtype=np.uint), (0, 4)),
        ([0., 1, 2, 3], (0,3)),
        # Complex comparison works as if they are floats
        ([[np.nan, -1-100j, 2], [-2, np.nan, 1+100j]], (-2, 2)),
        ([[np.nan, -1, 2-100j], [-2+100j, np.nan, 1]], (-2+100j, 2-100j)),
    ):
        for awt, kwargs in ((ArrayWriter, dict(check_scaling=False)),
                            (SlopeArrayWriter, {}),
                            (SlopeArrayWriter, dict(calc_scale=False)),
                            (SlopeInterArrayWriter, {}),
                            (SlopeInterArrayWriter, dict(calc_scale=False))):
            for out_type in NUMERIC_TYPES:
                has_nan = np.any(np.isnan(in_arr))
                try:
                    aw = awt(in_arr, out_type, **kwargs)
                except WriterError:
                    continue
                # Should not matter about the order of finite range method call
                # and has_nan property - test this is true
                assert_equal(aw.has_nan, has_nan)
                assert_equal(aw.finite_range(), res)
                aw = awt(in_arr, out_type, **kwargs)
                assert_equal(aw.finite_range(), res)
                assert_equal(aw.has_nan, has_nan)
                # Check float types work as complex
                in_arr = np.array(in_arr)
                if in_arr.dtype.kind == 'f':
                    c_arr = in_arr.astype(np.complex)
                    try:
                        aw = awt(c_arr, out_type, **kwargs)
                    except WriterError:
                        continue
                    aw = awt(c_arr, out_type, **kwargs)
                    assert_equal(aw.has_nan, has_nan)
                    assert_equal(aw.finite_range(), res)
            # Structured type cannot be nan and we can test this
            a = np.array([[1., 0, 1], [2, 3, 4]]).view([('f1', 'f')])
            aw = awt(a, a.dtype, **kwargs)
            assert_raises(TypeError, aw.finite_range)
            assert_false(aw.has_nan)
开发者ID:bpinsard,项目名称:nibabel,代码行数:60,代码来源:test_arraywriters.py


示例19: test_add_kubernetes_docker_host_networking

    def test_add_kubernetes_docker_host_networking(self):
        """
        Test CNI add in k8s docker when NetworkMode == host.
        """
        # Configure.
        self.cni_args = "K8S_POD_NAME=podname;K8S_POD_NAMESPACE=default"
        self.command = CNI_CMD_ADD
        ip4 = "10.0.0.1/32"
        ip6 = "0:0:0:0:0:ffff:a00:1"
        ipam_stdout = json.dumps({"ip4": {"ip": ip4}, 
                                  "ip6": {"ip": ip6}})
        self.set_ipam_result(0, ipam_stdout, "")

        # Create plugin.
        p = self.create_plugin()

        # Mock NetworkMode == host.
        inspect_result = {"HostConfig": {"NetworkMode": "host"}}
        self.m_docker_client().inspect_container.return_value = inspect_result

        # Execute.
        with assert_raises(SystemExit) as err:
            p.execute()
        e = err.exception

        # Assert success.
        assert_equal(e.code, 0)
        
        # Assert an endpoint was not created.
        assert_false(self.client.create_endpoint.called)
开发者ID:MikeSpreitzer,项目名称:calico-cni,代码行数:30,代码来源:test_calico_cni.py


示例20: test_ext_eq

def test_ext_eq():
    ext = Nifti1Extension('comment', '123')
    assert_true(ext == ext)
    assert_false(ext != ext)
    ext2 = Nifti1Extension('comment', '124')
    assert_false(ext == ext2)
    assert_true(ext != ext2)
开发者ID:hanke,项目名称:nibabel,代码行数:7,代码来源:test_nifti1.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tools.assert_greater函数代码示例发布时间:2022-05-27
下一篇:
Python tools.assert_equals函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap