本文整理汇总了Python中pyquery.PyQuery.is_方法的典型用法代码示例。如果您正苦于以下问题:Python PyQuery.is_方法的具体用法?Python PyQuery.is_怎么用?Python PyQuery.is_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyquery.PyQuery
的用法示例。
在下文中一共展示了PyQuery.is_方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_redirect
# 需要导入模块: from pyquery import PyQuery [as 别名]
# 或者: from pyquery.PyQuery import is_ [as 别名]
def test_redirect(base_url, selenium, method, uri):
HEADING_TEXT = 'Maintenance Mode'
HEADING_SELECTOR = '#content-main > h1'
MM_URL_TEMPLATE = '{locale}/maintenance-mode'
locale = 'en-US'
url = urljoin(base_url, uri.format(locale=locale))
if method.lower() == 'get':
# We do a get on the given URL but wait for the
# maintenance-mode page to load via redirection.
selenium.get(url)
mm_page = BasePage(selenium, base_url, locale=locale)
mm_page.URL_TEMPLATE = MM_URL_TEMPLATE
mm_page.wait_for_page_to_load()
mm_heading = mm_page.find_element(By.CSS_SELECTOR, HEADING_SELECTOR)
assert mm_heading.is_displayed()
assert HEADING_TEXT in mm_heading.text
assert mm_page.is_maintenance_mode_banner_displayed
assert not mm_page.header.is_signin_displayed
else:
request_method = getattr(requests, method.lower())
resp = request_method(url, allow_redirects=True)
# The final response should be a successful load of the
# maintenance-mode page in the given locale.
assert resp.status_code == 200
assert resp.url == urljoin(base_url,
MM_URL_TEMPLATE.format(locale=locale))
pq = PyQuery(resp.text)
assert HEADING_TEXT in pq(HEADING_SELECTOR).text()
assert (BasePage.MM_BANNER_TEXT in
pq(BasePage.MM_BANNER_SELECTOR).text())
assert not pq.is_(BasePage.Header.SIGNIN_SELECTOR)