本文整理汇总了Python中test_utils.eq_函数的典型用法代码示例。如果您正苦于以下问题:Python eq_函数的具体用法?Python eq_怎么用?Python eq_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eq_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_frequent_by_date
def test_frequent_by_date(self):
"""Test frequent terms by date."""
ts = Term.objects.frequent(date_end=self.split_date)
eq_(ts[0].term, self.t1.term)
ts = Term.objects.frequent(date_start=self.split_date)
eq_(ts[0].term, self.t2.term)
开发者ID:ryansnyder,项目名称:reporter,代码行数:7,代码来源:test_models.py
示例2: test_set_domains_no_args
def test_set_domains_no_args(self):
Site.objects.create(pk=1, domain='hi', name='hi')
Site.objects.create(pk=2, domain='there', name='there')
cron.set_domains(None, None)
# Assert NOOP
eq_(Site.objects.get(id=1).domain, 'hi')
eq_(Site.objects.get(id=2).domain, 'there')
开发者ID:LegNeato,项目名称:input.mozilla.org,代码行数:7,代码来源:test_cron.py
示例3: test_locale_fallback
def test_locale_fallback(self):
"""
Any specific flavor of a language (xx-YY) should return its generic
site (xx) if it exists.
"""
patterns = (
('fR,de;q=0.7', 'fr'),
('zh,fr;q=0.7', 'zh-CN'),
('eN,fr;q=0.7', 'en-US'),
('en,de;q=0.8', 'en-US'),
('en-us,en;q=0.7,de;q=0.8', 'en-US'),
('fr-FR,de-DE;q=0.5', 'fr'),
('zh, en-us;q=0.8, en;q=0.6', 'zh-CN'),
('xx-YY,es-ES;q=0.7,de-DE;q=0.5', 'es'),
('German', 'en-US'), # invalid
# bug 582075
('nb,no;q=0.8,nn;q=0.6,en-us;q=0.4,en;q=0.2', 'nb-NO'),
# bug 629115
('en-US,en;q=0.9,ro;q=0.8,ja;q=0.7,fr;q=0.6', 'en-US'),
)
for pattern in patterns:
r = self.client.get('/', HTTP_ACCEPT_LANGUAGE=pattern[0])
eq_(r.status_code, 301)
did_it_work = r['Location'].rstrip('/').endswith(pattern[1])
self.assertTrue(did_it_work, "%s didn't match %s" % pattern)
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:26,代码来源:test_middleware.py
示例4: test_trans_interpolation
def test_trans_interpolation():
"""Trans block with interpolation should be escaped."""
s = """
{% trans what="<a>" %}
this is a <b>{{ what }}</b>
{% endtrans %}
""".strip()
eq_(render(s), 'this is a <b><a></b>')
开发者ID:andymckay,项目名称:tower,代码行数:8,代码来源:test_templates.py
示例5: test_platform_name
def test_platform_name():
"""Show platform name or ID if unknown."""
o = Opinion()
o.platform = 'win7'
eq_(o.platform_name, WINDOWS_7.pretty)
o.platform = 'win25' # Unknown ID
eq_(o.platform_name, 'win25')
开发者ID:ryansnyder,项目名称:reporter,代码行数:8,代码来源:test_models.py
示例6: test_product_name
def test_product_name():
"""Show product name or ID if unknown."""
o = Opinion()
o.product = FIREFOX.id
eq_(o.product_name, FIREFOX.pretty)
o.product = 17 # Unknown ID
eq_(o.product_name, 17)
开发者ID:ryansnyder,项目名称:reporter,代码行数:8,代码来源:test_models.py
示例7: test_mobilesite_detection
def test_mobilesite_detection(self, mock):
"""Make sure we switch to the mobile site if the domain matches."""
def side_effect(*args, **kwargs):
class FakeSite(object):
id = settings.MOBILE_SITE_ID
return FakeSite()
mock.side_effect = side_effect
# Get the front page. Since we mocked the Site model, the URL we
# pass here does not matter.
self.client.get('/', HTTP_HOST='m.example.com')
eq_(settings.SITE_ID, settings.MOBILE_SITE_ID)
开发者ID:LegNeato,项目名称:input.mozilla.org,代码行数:12,代码来源:test_middleware.py
示例8: test_cached_property
def test_cached_property(self):
class A(object):
_foo = 1
@decorators.cached_property
def foo(self):
return self._foo
a = A()
eq_(a.foo, 1)
a._foo = 2
eq_(a.foo, 1)
开发者ID:fwenzel,项目名称:reporter,代码行数:12,代码来源:test_decorators.py
示例9: test_channel_in_get
def test_channel_in_get(self):
for ch in CHANNELS:
request = Mock()
request.path_info = '/'
request.GET = dict(channel=ch)
p = urlresolvers.Prefixer(request)
eq_(p.get_channel(), ch)
# Invalid channel
request = Mock()
request.path_info = '/'
request.GET = dict(channel='bogus')
p = urlresolvers.Prefixer(request)
eq_(p.get_channel(), settings.DEFAULT_CHANNEL)
开发者ID:ryansnyder,项目名称:reporter,代码行数:14,代码来源:test_middleware.py
示例10: test_forward_mobile
def test_forward_mobile(self, mock):
fake_mobile_domain = 'mymobiledomain.example.com'
def side_effect(*args, **kwargs):
class FakeSite(object):
id = settings.MOBILE_SITE_ID
domain = fake_mobile_domain
return FakeSite()
mock.side_effect = side_effect
r = self.mclient.get(reverse('dashboard') + '?foo=bar')
eq_(r.status_code, 302)
eq_(r['Location'], 'http://' + fake_mobile_domain +
reverse('dashboard') + '?foo=bar')
开发者ID:fwenzel,项目名称:reporter,代码行数:14,代码来源:test_decorators.py
示例11: test_mobile_device_detection
def test_mobile_device_detection(self, mock):
"""
Requests to front page and submission pages should forward mobile
users to mobile site.
"""
fake_mobile_domain = 'mymobiledomain.example.com'
def side_effect(*args, **kwargs):
class FakeSite(object):
id = settings.MOBILE_SITE_ID
domain = fake_mobile_domain
return FakeSite()
mock.side_effect = side_effect
# URLs that should allow Mobile detection
urls = (
reverse('dashboard', channel='beta'),
reverse('feedback.happy'),
reverse('feedback.sad'),
reverse('feedback.idea'),
reverse('feedback'),
)
# User Agent Patterns: (UA, forward: true/false?)
ua_patterns = (
# Fx
('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; '
'rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13', False),
# MSIE
('Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)',
False),
# Fennec
('Mozilla/5.0 (X11; U; Linux armv6l; fr; rv:1.9.1b1pre) Gecko/'
'20081005220218 Gecko/2008052201 Fennec/0.9pre', True),
# iPod touch
('Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 '
'(KHTML, like Gecko) Version/3.0 Mobile/3A101a Safari/419.3',
True),
)
for test_url in urls:
for ua, forward_this in ua_patterns:
r = self.client.get(test_url, HTTP_USER_AGENT=ua)
if forward_this:
eq_(r.status_code, 301)
assert r['Location'].find(fake_mobile_domain) >= 0
else:
assert (r.status_code == 200 or # Page is served, or:
r.status_code / 100 == 3 and # some redirect...
# ... but not to the mobile domain.
r['Location'].find(fake_mobile_domain) == -1)
开发者ID:ryansnyder,项目名称:reporter,代码行数:50,代码来源:test_decorators.py
示例12: test_split_queryset
def test_split_queryset():
"""Split a queryset into pieces."""
# Mock queryset object: List with qs-style count function.
class MockQs(list):
def count(self):
return len(self)
bucket_size = api.cron.BUCKET_SIZE
try:
api.cron.BUCKET_SIZE = 10
my_qs = MockQs(range(100))
splits = list(_split_queryset(my_qs))
eq_(len(splits), 10)
finally:
api.cron.BUCKET_SIZE = bucket_size
开发者ID:LegNeato,项目名称:input.mozilla.org,代码行数:16,代码来源:tests.py
示例13: test_forward_mobile
def test_forward_mobile(self, mock):
fake_mobile_domain = 'mymobiledomain.example.com'
populate(1)
id = Opinion.objects.values_list('id', flat=True)[0]
def side_effect(*args, **kwargs):
class FakeSite(object):
id = settings.MOBILE_SITE_ID
domain = fake_mobile_domain
return FakeSite()
mock.side_effect = side_effect
r = self.mclient.get(reverse('opinion.detail', args=[id]) +
'?foo=bar')
eq_(r.status_code, 302)
eq_(r['Location'], 'http://' + fake_mobile_domain +
reverse('opinion.detail', args=[id]) + '?foo=bar')
开发者ID:LegNeato,项目名称:input.mozilla.org,代码行数:18,代码来源:test_decorators.py
示例14: test_fake_locale
def test_fake_locale(self):
r = self.factory.get('/zf/beta')
p = urlresolvers.Prefixer(r)
eq_(p.locale, '')
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:4,代码来源:test_middleware.py
示例15: test_locale_in_get
def test_locale_in_get(self):
request = Mock()
request.path_info = '/'
request.GET = dict(lang='en-US')
p = urlresolvers.Prefixer(request)
eq_(p.get_language(), 'en-US')
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:6,代码来源:test_middleware.py
示例16: test_no_locale
def test_no_locale(self):
request = Mock()
request.path_info = '/beta'
p = urlresolvers.Prefixer(request)
eq_(p.locale, '')
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:5,代码来源:test_middleware.py
示例17: test_almost_locale
def test_almost_locale(self):
request = Mock()
request.path_info = '/en/'
p = urlresolvers.Prefixer(request)
eq_(p.locale, 'en-US')
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:5,代码来源:test_middleware.py
示例18: test_x_frame_options
def test_x_frame_options(self):
"""Ensure X-Frame-Options middleware works as expected."""
r = self.client.get('/')
eq_(r['x-frame-options'], 'DENY')
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:4,代码来源:test_middleware.py
示例19: test_no_prefixer
def test_no_prefixer(self):
urlresolvers.clean_url_prefixes()
eq_(urlresolvers.reverse('feedback'), '/feedback')
开发者ID:cturra,项目名称:input.mozilla.org,代码行数:3,代码来源:test_middleware.py
示例20: test_isotime_fake_time
def test_isotime_fake_time(self):
eq_(helpers.isotime(None), None)
开发者ID:ryansnyder,项目名称:reporter,代码行数:2,代码来源:test_helpers.py
注:本文中的test_utils.eq_函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论