本文整理汇总了Python中purl.URL.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python URL.from_string方法的具体用法?Python URL.from_string怎么用?Python URL.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类purl.URL
的用法示例。
在下文中一共展示了URL.from_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def setUp(self):
self.unicode_param = 'значение'
# Python 2.6 requires bytes for quote
self.urlencoded_param = quote(self.unicode_param.encode('utf8'))
url = 'http://www.google.com/blog/article/1?q=' + self.urlencoded_param
self.ascii_url = URL.from_string(url.encode('ascii'))
# django request.get_full_path() returns url as unicode
self.unicode_url = URL.from_string(url)
示例2: perform_action
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def perform_action(self):
basket = Mock()
basket.id = 1
basket.total_incl_tax = D('200')
basket.all_lines = Mock(return_value=[])
methods = [Free()]
url_str = get_paypal_url(basket, methods)
self.url = URL.from_string(url_str)
示例3: perform_action
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def perform_action(self):
basket = Mock()
basket.id = 1
basket.total_incl_tax = D('200')
basket.all_lines = Mock(return_value=[])
basket.offer_discounts = []
basket.voucher_discounts = []
basket.shipping_discounts = []
methods = [Free()]
url_str = get_paypal_url(basket, methods, paypal_params=self.paypal_params)
self.url = URL.from_string(url_str)
示例4: test_missing_shipping_address
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_missing_shipping_address(self):
from paypal.express.views import RedirectView
with patch.object(RedirectView, 'as_payment_method') as as_payment_method:
as_payment_method.return_value = True
url = reverse('paypal-redirect')
self.add_product_to_basket()
response = self.client.get(url)
self.assertEqual(
reverse('checkout:shipping-address'),
URL.from_string(response['Location']).path()
)
示例5: setUp
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def setUp(self):
self.url_str = 'http://www.google.com/search/?q=testing#fragment'
self.url = URL.from_string(self.url_str)
示例6: test_negative_equality_comparison
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_negative_equality_comparison(self):
self.assertNotEqual(URL.from_string('http://google.com'),
URL.from_string('https://google.com'))
示例7: test_urls_can_be_pickled
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_urls_can_be_pickled(self):
u = URL.from_string('http://google.com')
pickle.dumps(u)
示例8: test_auth_in_netloc
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_auth_in_netloc(self):
url = URL.from_string('ftp://user:[email protected]')
self.assertEqual('user:[email protected]', url.netloc())
示例9: test_username_extraction
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_username_extraction(self):
url = URL.from_string('ftp://user:[email protected]')
self.assertEqual('user', url.username())
self.assertEqual('pw', url.password())
示例10: test_set_path
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_set_path(self):
url = URL.from_string('http://www.google.com/').path('search')
self.assertEqual('/search', url.path())
示例11: test_set_host
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_set_host(self):
url = URL.from_string('http://www.google.com/').host('maps.google.com')
self.assertEqual('maps.google.com', url.host())
示例12: test_set_scheme
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_set_scheme(self):
url = URL.from_string('http://www.google.com/').scheme('https')
self.assertEqual('https', url.scheme())
示例13: test_set_fragment
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_set_fragment(self):
url = URL.from_string('http://www.google.com/').fragment('hello')
self.assertEqual('hello', url.fragment())
示例14: test_port_in_netloc
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_port_in_netloc(self):
url = URL.from_string('http://localhost:5000')
self.assertEqual('localhost', url.host())
self.assertEqual(5000, url.port())
示例15: test_urls_can_be_pickled_and_restored
# 需要导入模块: from purl import URL [as 别名]
# 或者: from purl.URL import from_string [as 别名]
def test_urls_can_be_pickled_and_restored(self):
u = URL.from_string('http://google.com')
pickled = pickle.dumps(u)
v = pickle.loads(pickled)
self.assertEqual(u, v)