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


Python tools.assert_equal函数代码示例

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


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

示例1: test_lazy_load_index

def test_lazy_load_index():
    f = StringIO()
    dump({'wakka': 42}, f)
    f.seek(0)
    lj = LazyJSON(f)
    assert_equal({'wakka': 10, '__total__': 0}, lj.offsets)
    assert_equal({'wakka': 2, '__total__': 14}, lj.sizes)
开发者ID:Cynary,项目名称:xonsh,代码行数:7,代码来源:test_lazyjson.py

示例2: test_default_diverging_vlims

    def test_default_diverging_vlims(self):

        p = mat._HeatMapper(self.df_norm, **self.default_kws)
        vlim = max(abs(self.x_norm.min()), abs(self.x_norm.max()))
        nt.assert_equal(p.vmin, -vlim)
        nt.assert_equal(p.vmax, vlim)
        nt.assert_true(p.divergent)
开发者ID:petebachant,项目名称:seaborn,代码行数:7,代码来源:test_matrix.py

示例3: test_tickabels_off

 def test_tickabels_off(self):
     kws = self.default_kws.copy()
     kws['xticklabels'] = False
     kws['yticklabels'] = False
     p = mat._HeatMapper(self.df_norm, **kws)
     nt.assert_equal(p.xticklabels, [])
     nt.assert_equal(p.yticklabels, [])
开发者ID:petebachant,项目名称:seaborn,代码行数:7,代码来源:test_matrix.py

示例4: test_fetch_library_name_personal

    def test_fetch_library_name_personal(self):
        self.node_settings.library_id = 'personal'

        assert_equal(
            self.node_settings.fetch_library_name,
            'My library'
        )
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:7,代码来源:test_models.py

示例5: test_selected_library_name_empty

    def test_selected_library_name_empty(self):
        self.node_settings.library_id = None

        assert_equal(
            self.node_settings.fetch_library_name,
            ''
        )
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:7,代码来源:test_models.py

示例6: test_fail_fetch_haxby_simple

def test_fail_fetch_haxby_simple():
    # Test a dataset fetching failure to validate sandboxing
    local_url = "file://" + os.path.join(datadir, "pymvpa-exampledata.tar.bz2")
    datasetdir = os.path.join(tmpdir, 'haxby2001_simple', 'pymvpa-exampledata')
    os.makedirs(datasetdir)
    # Create a dummy file. If sandboxing is successful, it won't be overwritten
    dummy = open(os.path.join(datasetdir, 'attributes.txt'), 'w')
    dummy.write('stuff')
    dummy.close()

    path = 'pymvpa-exampledata'

    opts = {'uncompress': True}
    files = [
        (os.path.join(path, 'attributes.txt'), local_url, opts),
        # The following file does not exists. It will cause an abortion of
        # the fetching procedure
        (os.path.join(path, 'bald.nii.gz'), local_url, opts)
    ]

    assert_raises(IOError, utils._fetch_files,
                  os.path.join(tmpdir, 'haxby2001_simple'), files,
                  verbose=0)
    dummy = open(os.path.join(datasetdir, 'attributes.txt'), 'r')
    stuff = dummy.read(5)
    dummy.close()
    assert_equal(stuff, 'stuff')
开发者ID:bcipolli,项目名称:nilearn,代码行数:27,代码来源:test_func.py

示例7: test_subproc_hello_mom_second

def test_subproc_hello_mom_second():
    fst = "echo 'hello'"
    sec = "echo 'mom'"
    s = '{0}; {1}'.format(fst, sec)
    exp = '{0}; $[{1}]'.format(fst, sec)
    obs = subproc_toks(s, lexer=LEXER, mincol=len(fst), returnline=True)
    assert_equal(exp, obs)
开发者ID:gforsyth,项目名称:xonsh,代码行数:7,代码来源:test_tools.py

示例8: test_subproc_hello_mom_first

def test_subproc_hello_mom_first():
    fst = "echo 'hello'"
    sec = "echo 'mom'"
    s = '{0}; {1}'.format(fst, sec)
    exp = '$[{0}]; {1}'.format(fst, sec)
    obs = subproc_toks(s, lexer=LEXER, maxcol=len(fst)+1, returnline=True)
    assert_equal(exp, obs)
开发者ID:gforsyth,项目名称:xonsh,代码行数:7,代码来源:test_tools.py

示例9: test_unicode_decode_error

def test_unicode_decode_error():
    # decode_error default to strict, so this should fail
    # First, encode (as bytes) a unicode string.
    text = "J'ai mang\xe9 du kangourou  ce midi, c'\xe9tait pas tr\xeas bon."
    text_bytes = text.encode('utf-8')

    # Then let the Analyzer try to decode it as ascii. It should fail,
    # because we have given it an incorrect encoding.
    wa = CountVectorizer(ngram_range=(1, 2), encoding='ascii').build_analyzer()
    assert_raises(UnicodeDecodeError, wa, text_bytes)

    ca = CountVectorizer(analyzer='char', ngram_range=(3, 6),
                         encoding='ascii').build_analyzer()
    assert_raises(UnicodeDecodeError, ca, text_bytes)

    # Check the old interface
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")

        ca = CountVectorizer(analyzer='char', ngram_range=(3, 6),
                             charset='ascii').build_analyzer()
        assert_raises(UnicodeDecodeError, ca, text_bytes)

        assert_equal(len(w), 1)
        assert_true(issubclass(w[0].category, DeprecationWarning))
        assert_true("charset" in str(w[0].message).lower())
开发者ID:BloodD,项目名称:scikit-learn,代码行数:26,代码来源:test_text.py

示例10: test_wilsonLT_Defaults_FeatureInput1

def test_wilsonLT_Defaults_FeatureInput1():
    '''Confirm default FeatureInput values.'''
    G = la.input_.Geometry
    load_params = {
        'R': 12e-3,                                    # specimen radius
        'a': 7.5e-3,                                   # support ring radius
        'p': 5,                                        # points/layer
        'P_a': 1,                                      # applied load
        'r': 2e-4,                                     # radial distance from center loading
    }

#     mat_props = {'HA' : [5.2e10, 0.25],
#                  'PSu' : [2.7e9, 0.33],
#                  }

    mat_props = {'Modulus': {'HA': 5.2e10, 'PSu': 2.7e9},
                 'Poissons': {'HA': 0.25, 'PSu': 0.33}}

    '''Find way to compare materials DataFrames and Geo_objects .'''
    actual = dft.FeatureInput
    expected = {
        'Geometry': G('400-[200]-800'),
        'Parameters': load_params,
        'Properties': mat_props,
        'Materials': ['HA', 'PSu'],
        'Model': 'Wilson_LT',
        'Globals': None
    }
    ##del actual['Geometry']
    ##del actual['Materials']
    nt.assert_equal(actual, expected)
开发者ID:par2,项目名称:lamana,代码行数:31,代码来源:test_Wilson_LT.py

示例11: test_recursive_solve

def test_recursive_solve():
    rec_sudoku = " ,  ,  ,  , 5, 3,  ,  ,  ;\n" + \
                 "1,  ,  , 6,  ,  ,  ,  , 8;\n" + \
                 " , 5,  ,  ,  , 1,  , 4,  ;\n" + \
                 "4,  ,  ,  , 9,  , 5, 3,  ;\n" + \
                 " ,  , 9, 7,  , 6, 8,  ,  ;\n" + \
                 " , 2, 7,  , 3,  ,  ,  , 6;\n" + \
                 " , 4,  , 1,  ,  ,  , 8,  ;\n" + \
                 "2,  ,  ,  ,  , 7,  ,  , 1;\n" + \
                 " ,  ,  , 3, 2,  ,  ,  ,  ;\n"

    solution = "6, 8, 4, 2, 5, 3, 1, 7, 9;\n" + \
               "1, 9, 3, 6, 7, 4, 2, 5, 8;\n" + \
               "7, 5, 2, 9, 8, 1, 6, 4, 3;\n" + \
               "4, 1, 6, 8, 9, 2, 5, 3, 7;\n" + \
               "5, 3, 9, 7, 1, 6, 8, 2, 4;\n" + \
               "8, 2, 7, 4, 3, 5, 9, 1, 6;\n" + \
               "3, 4, 5, 1, 6, 9, 7, 8, 2;\n" + \
               "2, 6, 8, 5, 4, 7, 3, 9, 1;\n" + \
               "9, 7, 1, 3, 2, 8, 4, 6, 5;\n"

    sudoku = Sudoku()
    sudoku.read_string(rec_sudoku)
    sudoku.recursive_solve()
    assert_equal(str(sudoku), solution)
开发者ID:ps-weber,项目名称:sudoku,代码行数:25,代码来源:test_sudoku.py

示例12: test_equality_encoding_realm_emptyValues

    def test_equality_encoding_realm_emptyValues(self):
        expected_value = ({
            'oauth_nonce': ['4572616e48616d6d65724c61686176'],
            'oauth_timestamp': ['137131200'],
            'oauth_consumer_key': ['0685bd9184jfhq22'],
            'oauth_something': [' Some Example'],
            'oauth_signature_method': ['HMAC-SHA1'],
            'oauth_version': ['1.0'],
            'oauth_token': ['ad180jjd733klru7'],
            'oauth_empty': [''],
            'oauth_signature': ['wOJIO9A2W5mFwDgiDvZbTSMK/PY='],
            }, 'Examp%20le'
        )
        assert_equal(expected_value, parse_authorization_header_value('''\
            OAuth\
\
            realm="Examp%20le",\
            oauth_consumer_key="0685bd9184jfhq22",\
            oauth_token="ad180jjd733klru7",\
            oauth_signature_method="HMAC-SHA1",\
            oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",\
            oauth_timestamp="137131200",\
            oauth_nonce="4572616e48616d6d65724c61686176",\
            oauth_version="1.0",\
            oauth_something="%20Some+Example",\
            oauth_empty=""\
        '''), "parsing failed.")
开发者ID:davidlehn,项目名称:pyoauth,代码行数:27,代码来源:test_pyoauth_protocol.py

示例13: _req

    def _req(cls, method, *args, **kwargs):
        use_token = kwargs.pop('use_token', True)
        token = kwargs.pop('token', None)
        if use_token and token is None:
            admin = kwargs.pop('admin', False)
            if admin:
                if cls._admin_token is None:
                    cls._admin_token = get_auth_token(ADMIN_USERNAME,
                        ADMIN_PASSWORD)
                token = cls._admin_token
            else:
                if cls._token is None:
                    cls._token = get_auth_token(USERNAME, PASSWORD)
                token = cls._token

        if use_token:
            headers = kwargs.get('headers', {})
            headers.setdefault('Authorization', 'Token ' + token)
            kwargs['headers'] = headers

        expected = kwargs.pop('expected', 200)
        resp = requests.request(method, *args, **kwargs)
        if expected is not None:
            if hasattr(expected, '__iter__'):
                assert_in(resp.status_code, expected,
                    "Expected http status in %s, received %s" % (expected,
                        resp.status_code))
            else:
                assert_equal(resp.status_code, expected,
                    "Expected http status %s, received %s" % (expected,
                        resp.status_code))
        return resp
开发者ID:DionysosLai,项目名称:seahub,代码行数:32,代码来源:apitestbase.py

示例14: test_valid_signature

 def test_valid_signature(self):
     for example in self._examples:
         client_shared_secret = example["private_key"]
         client_certificate = example["certificate"]
         public_key = example["public_key"]
         url = example["url"]
         method = example["method"]
         oauth_params = example["oauth_params"]
         expected_signature = example["oauth_signature"]
         # Using the RSA private key.
         assert_equal(expected_signature,
                      generate_rsa_sha1_signature(client_shared_secret,
                                              method=method,
                                              url=url,
                                              oauth_params=oauth_params
                                              )
         )
         # Using the X.509 certificate.
         assert_true(verify_rsa_sha1_signature(
             client_certificate, expected_signature,
             method, url, oauth_params))
         # Using the RSA public key.
         assert_true(verify_rsa_sha1_signature(
             public_key, expected_signature,
             method, url, oauth_params))
开发者ID:davidlehn,项目名称:pyoauth,代码行数:25,代码来源:test_pyoauth_protocol.py

示例15: test_valid_base_string

 def test_valid_base_string(self):
     base_string = generate_signature_base_string("POST",
                                                   "http://example.com/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q"
                                                   ,
                                                   self.oauth_params)
     assert_equal(base_string,
                  "POST&http%3A%2F%2Fexample.com%2Frequest&a2%3Dr%2520b%26a3%3D2%2520q%26a3%3Da%26b5%3D%253D%25253D%26c%2540%3D%26c2%3D%26oauth_consumer_key%3D9djdj82h48djs9d2%26oauth_nonce%3D7d8f3e4a%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D137131201%26oauth_token%3Dkkk9d7dh3k39sjv7")
开发者ID:davidlehn,项目名称:pyoauth,代码行数:7,代码来源:test_pyoauth_protocol.py


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