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


Python tools.assert_false函数代码示例

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


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


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