本文整理汇总了Python中nose.tools.assert_equals方法的典型用法代码示例。如果您正苦于以下问题:Python tools.assert_equals方法的具体用法?Python tools.assert_equals怎么用?Python tools.assert_equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.tools
的用法示例。
在下文中一共展示了tools.assert_equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parameters
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_parameters(connpath):
vehicle = connect(connpath)
# When called on startup, parameter (may!) be none.
# assert_equals(vehicle.parameters.get('THR_MIN', wait_ready=False), None)
# With wait_ready, it should not be none.
assert_not_equals(vehicle.parameters.get('THR_MIN', wait_ready=True), None)
try:
assert_not_equals(vehicle.parameters['THR_MIN'], None)
except:
assert False
# Garbage value after all parameters are downloaded should be None.
assert_equals(vehicle.parameters.get('xXx_extreme_garbage_value_xXx', wait_ready=True), None)
vehicle.close()
示例2: test_setting
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_setting(connpath):
vehicle = connect(connpath, wait_ready=True)
assert_not_equals(vehicle.parameters['THR_MIN'], None)
result = {'success': False}
@vehicle.parameters.on_attribute('THR_MIN')
def listener(self, name, value):
result['success'] = (name == 'THR_MIN' and value == 3.000)
vehicle.parameters['THR_MIN'] = 3.000
# Wait a bit.
i = 5
while not result['success'] and i > 0:
time.sleep(1)
i = i - 1
assert_equals(result['success'], True)
vehicle.close()
示例3: test_hybrid_dois
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_hybrid_dois(self, test_data):
(doi, fulltext_url, license, color) = test_data
# because cookies breaks the cache pickling
# for doi_start in ["10.1109", "10.1161", "10.1093", "10.1007", "10.1039"]:
# if doi.startswith(doi_start):
requests_cache.uninstall_cache()
my_pub = pub.lookup_product_by_doi(doi)
my_pub.refresh()
logger.info(u"\n\nwas looking for {}, got {}".format(fulltext_url, my_pub.fulltext_url))
logger.info(u"https://api.unpaywall.org/v2/{}?email=me".format(doi))
logger.info(u"doi: https://doi.org/{}".format(doi))
logger.info(u"license: {}".format(my_pub.license))
logger.info(u"oa_color: {}".format(my_pub.oa_color))
logger.info(u"evidence: {}".format(my_pub.evidence))
if my_pub.error:
logger.info(my_pub.error)
assert_equals(my_pub.error, "")
assert_equals(my_pub.fulltext_url, fulltext_url)
# assert_equals(my_pub.license, license)
assert_equals(my_pub.error, "")
示例4: test_chorus_dois
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_chorus_dois(self, test_data):
doi = test_data
# because cookies breaks the cache pickling
# for doi_start in ["10.1109", "10.1161", "10.1093", "10.1007", "10.1039"]:
# if doi.startswith(doi_start):
requests_cache.uninstall_cache()
my_pub = pub.lookup_product_by_doi(doi)
if not my_pub:
logger.info(u"doi {} not in db, skipping".format(doi))
return
my_pub.refresh()
logger.info(u"https://api.unpaywall.org/v2/{}?email=me".format(doi))
logger.info(u"doi: https://doi.org/{}".format(doi))
logger.info(u"license: {}".format(my_pub.best_license))
logger.info(u"evidence: {}".format(my_pub.best_evidence))
logger.info(u"host: {}".format(my_pub.best_host))
if my_pub.error:
logger.info(my_pub.error)
assert_equals(my_pub.error, "")
assert_is_not_none(my_pub.fulltext_url)
示例5: test_package_update
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_package_update(self):
idf.plugin.create_country_codes()
helpers.call_action(
'package_create', name='test_package',
custom_text='this is my custom text', country_code='uk',
resources=[{
'url': 'http://test.com/',
'custom_resource_text': 'my custom resource',
}])
result = helpers.call_action(
'package_update',
name='test_package',
custom_text='this is my updated text',
country_code='ie',
resources=[{
'url': 'http://test.com/',
'custom_resource_text': 'updated custom resource',
}]
)
nt.assert_equals('this is my updated text', result['custom_text'])
nt.assert_equals([u'ie'], result['country_code'])
nt.assert_equals('updated custom resource',
result['resources'][0]['custom_resource_text'])
示例6: test_recarray
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_recarray():
import numpy
from numpy.testing.utils import assert_array_equal
for shape in SHAPES:
for dtype in [
[('f', float), ('s', '|S10')],
[('n', int), ('s', '|S1'), ('u', 'uint32')],
]:
A = numpy.empty(shape, dtype=dtype)
_scrub_nan(A)
bufs = serialize_object(A)
B, r = unserialize_object(bufs)
yield nt.assert_equals(r, [])
yield nt.assert_equals(A.shape, B.shape)
yield nt.assert_equals(A.dtype, B.dtype)
yield assert_array_equal(A,B)
示例7: test_numpy_in_seq
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_numpy_in_seq():
import numpy
from numpy.testing.utils import assert_array_equal
for shape in SHAPES:
for dtype in DTYPES:
A = numpy.empty(shape, dtype=dtype)
_scrub_nan(A)
bufs = serialize_object((A,1,2,b'hello'))
canned = pickle.loads(bufs[0])
yield nt.assert_true(canned[0], CannedArray)
tup, r = unserialize_object(bufs)
B = tup[0]
yield nt.assert_equals(r, [])
yield nt.assert_equals(A.shape, B.shape)
yield nt.assert_equals(A.dtype, B.dtype)
yield assert_array_equal(A,B)
示例8: test_genelatex_no_wrap
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_genelatex_no_wrap():
"""
Test genelatex with wrap=False.
"""
def mock_kpsewhich(filename):
assert False, ("kpsewhich should not be called "
"(called with {0})".format(filename))
with monkeypatch(latextools, "kpsewhich", mock_kpsewhich):
nt.assert_equals(
'\n'.join(latextools.genelatex("body text", False)),
r'''\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{bm}
\pagestyle{empty}
\begin{document}
body text
\end{document}''')
示例9: test_genelatex_wrap_with_breqn
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_genelatex_wrap_with_breqn():
"""
Test genelatex with wrap=True for the case breqn.sty is installed.
"""
def mock_kpsewhich(filename):
nt.assert_equals(filename, "breqn.sty")
return "path/to/breqn.sty"
with monkeypatch(latextools, "kpsewhich", mock_kpsewhich):
nt.assert_equals(
'\n'.join(latextools.genelatex("x^2", True)),
r'''\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{breqn}
\pagestyle{empty}
\begin{document}
\begin{dmath*}
x^2
\end{dmath*}
\end{document}''')
示例10: test_get_sdb_path
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_get_sdb_path(self, mock_get, mock_sdb_id):
""" Test that get_sdb_path returns the correct path """
sdb_data = {
"id": "5f0-99-414-bc-e5909c",
"name": "Disco Events",
"description": "Studio 54",
"path": "app/disco-events/"
}
mock_resp = self._mock_response(content=json.dumps(sdb_data))
mock_get.return_value = mock_resp
path = self.client.get_sdb_path("Disco Events")
assert_equals(path, sdb_data['path'])
assert_in('X-Cerberus-Client', self.client.HEADERS)
mock_get.assert_called_with(
self.cerberus_url + '/v2/safe-deposit-box/5f0-99-414-bc-e5909c/',
headers=self.client.HEADERS
)
示例11: test_getting_a_secret
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_getting_a_secret(self, mock_get):
""" get_secret: Testing the correct secret is returned"""
secret_data = {
"data": {
"mykey": "mysecretdata",
"myotherkey": "moretopsecretstuff"
}
}
mock_resp = self._mock_response(content=json.dumps(secret_data))
mock_get.return_value = mock_resp
secret = self.client.get_secret('fake/path', 'myotherkey')
# check to make sure we got the right secret
assert_equals(secret, 'moretopsecretstuff')
assert_in('X-Cerberus-Client', self.client.HEADERS)
mock_get.assert_called_with(
self.cerberus_url + '/v1/secret/fake/path',
params={'versionId': 'CURRENT'}, headers=self.client.HEADERS
)
示例12: test_getting_secrets_data
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_getting_secrets_data(self, mock_get):
""" get_secrets_data: Testing the correct secrets are returned"""
secret_data = {
"data": {
"sushi": "ikenohana",
"ramen": "yuzu"
}
}
mock_resp = self._mock_response(content=json.dumps(secret_data))
mock_get.return_value = mock_resp
secrets = self.client.get_secrets_data('fake/path')
# check to make sure we got the right secret
assert_equals(secrets['sushi'], 'ikenohana')
assert_equals(secrets['ramen'], 'yuzu')
assert_in('X-Cerberus-Client', self.client.HEADERS)
mock_get.assert_called_with(
self.cerberus_url + '/v1/secret/fake/path',
params={'versionId': 'CURRENT'}, headers=self.client.HEADERS
)
示例13: test_getting_secrets_data_version
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_getting_secrets_data_version(self, mock_get):
""" get_secrets_data: Testing the correct secrets are returned when a version is passed """
secret_data = {
"data": {
"sushi": "ikenohana",
"ramen": "yuzu"
}
}
mock_resp = self._mock_response(content=json.dumps(secret_data))
mock_get.return_value = mock_resp
secrets = self.client.get_secrets_data('fake/path', version='12345')
# check to make sure we got the right secret
assert_equals(secrets['sushi'], 'ikenohana')
assert_equals(secrets['ramen'], 'yuzu')
assert_in('X-Cerberus-Client', self.client.HEADERS)
mock_get.assert_called_with(
self.cerberus_url + '/v1/secret/fake/path',
params={'versionId': '12345'}, headers=self.client.HEADERS
)
示例14: test_open_dois
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_open_dois(self, test_data):
(doi, fulltext_url, license) = test_data
my_pub = pub.lookup_product_by_doi(doi)
my_pub.recalculate()
logger.info(u"was looking for {}, got {}\n\n".format(fulltext_url, my_pub.fulltext_url))
logger.info(u"https://api.unpaywall.org/v2/{}?email=me".format(doi))
logger.info(u"doi: https://doi.org/{}".format(doi))
logger.info(u"title: {}".format(my_pub.best_title))
logger.info(u"evidence: {}\n\n".format(my_pub.evidence))
if my_pub.error:
logger.info(my_pub.error)
assert_not_equals(my_pub.fulltext_url, None)
assert_equals(fulltext_url, my_pub.fulltext_url)
示例15: test_arxiv_dois
# 需要导入模块: from nose import tools [as 别名]
# 或者: from nose.tools import assert_equals [as 别名]
def test_arxiv_dois(self, test_data):
(doi, fulltext_url, license) = test_data
my_pub = pub.lookup_product_by_doi(doi)
my_pub.recalculate()
logger.info(u"was looking for {}, got {}\n\n".format(fulltext_url, my_pub.fulltext_url))
logger.info(u"https://api.unpaywall.org/v2/{}?email=me".format(doi))
logger.info(u"doi: https://doi.org/{}".format(doi))
logger.info(u"title: {}".format(my_pub.best_title))
logger.info(u"evidence: {}\n\n".format(my_pub.evidence))
if my_pub.error:
logger.info(my_pub.error)
assert_not_equals(my_pub.fulltext_url, None)
# not sure that the arxiv url will be the best one, but make sure it is one of them
urls = [loc.pdf_url for loc in my_pub.all_oa_locations]
assert_true(fulltext_url in urls)
# @data(*closed_dois)
# def test_closed_dois(self, test_data):
# (doi, fulltext_url, license) = test_data
# my_pub = pub.lookup_product_by_doi(doi)
# my_pub.recalculate()
#
# logger.info(u"was looking for {}, got {}\n\n".format(fulltext_url, my_pub.fulltext_url))
# logger.info(u"doi: https://doi.org/{}".format(doi))
# logger.info(u"title: {}".format(my_pub.best_title))
# logger.info(u"evidence: {}\n\n".format(my_pub.evidence))
# if my_pub.error:
# logger.info(my_pub.error)
#
# assert_equals(my_pub.fulltext_url, None)
#
# have to scrape the publisher pages to find these