[Python-modules-commits] [yarl] 01/08: Import yarl_0.11.0.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Fri Jun 30 13:09:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository yarl.
commit c0e15ae13eb375021d634686ae021a73d284c471
Author: Piotr Ożarowski <piotr at debian.org>
Date: Fri Jun 30 15:02:43 2017 +0200
Import yarl_0.11.0.orig.tar.gz
---
CHANGES.rst | 7 +
LICENSE | 2 +-
PKG-INFO | 9 +-
docs/api.rst | 2 +-
docs/conf.py | 2 +-
setup.cfg | 3 +-
tests/test_normalize_path.py | 21 ++
tests/test_pickle.py | 29 +++
tests/test_url.py | 481 ++++------------------------------------
tests/test_url_build.py | 124 +++++++++++
tests/test_url_cmp_and_hash.py | 89 ++++++++
tests/test_url_query.py | 72 ++++++
tests/test_url_update_netloc.py | 155 +++++++++++++
yarl.egg-info/PKG-INFO | 9 +-
yarl.egg-info/SOURCES.txt | 6 +
yarl/__init__.py | 69 ++++--
yarl/__init__.pyi | 1 +
yarl/_quoting.c | 2 +-
18 files changed, 629 insertions(+), 454 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 997b842..a97882f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,13 @@
CHANGES
=======
+0.11.0 (2017-06-26)
+-------------------
+
+* Normalize path #86
+
+* Clear query and fragment parts in `.with_path()` #85
+
0.10.3 (2017-06-13)
-------------------
diff --git a/LICENSE b/LICENSE
index 8dada3e..b46efde 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright {yyyy} {name of copyright owner}
+ Copyright 2016-2017, Andrew Svetlov
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/PKG-INFO b/PKG-INFO
index 6451c74..a467e00 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: yarl
-Version: 0.10.3
+Version: 0.11.0
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
@@ -164,6 +164,13 @@ Description: yarl
CHANGES
=======
+ 0.11.0 (2017-06-26)
+ -------------------
+
+ * Normalize path #86
+
+ * Clear query and fragment parts in `.with_path()` #85
+
0.10.3 (2017-06-13)
-------------------
diff --git a/docs/api.rst b/docs/api.rst
index b273150..6f9b057 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -461,7 +461,7 @@ section generates a new *URL* instance.
>>> URL('http://example.com:8888').with_port(None)
URL('http://example.com')
-.. method:: URL.with_path(path, encoded=False)
+.. method:: URL.with_path(path)
Return a new URL with *path* replaced, encode *path* if needed.
diff --git a/docs/conf.py b/docs/conf.py
index b53d5a4..196c4ad 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -80,7 +80,7 @@ master_doc = 'index'
# General information about the project.
project = 'yarl'
-copyright = '2016, Andrew Svetlov'
+copyright = '2016-2017, Andrew Svetlov'
author = 'Andrew Svetlov'
# The version info for the project you're documenting, acts as replacement for
diff --git a/setup.cfg b/setup.cfg
index 958c331..e4eba0b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,7 +2,6 @@
test = pytest
[egg_info]
-tag_date = 0
-tag_svn_revision = 0
tag_build =
+tag_date = 0
diff --git a/tests/test_normalize_path.py b/tests/test_normalize_path.py
new file mode 100644
index 0000000..d433c7b
--- /dev/null
+++ b/tests/test_normalize_path.py
@@ -0,0 +1,21 @@
+from yarl import _normalize_path as np
+
+
+def test_no_dots():
+ assert np('path/to') == 'path/to'
+
+
+def test_skip_dots():
+ assert np('path/./to') == 'path/to'
+
+
+def test_dot_at_end():
+ assert np('path/to/.') == 'path/to/'
+
+
+def test_double_dots():
+ assert np('path/../to') == 'to'
+
+
+def test_extra_double_dots():
+ assert np('path/../../to') == 'to'
diff --git a/tests/test_pickle.py b/tests/test_pickle.py
new file mode 100644
index 0000000..c856953
--- /dev/null
+++ b/tests/test_pickle.py
@@ -0,0 +1,29 @@
+import pickle
+
+from yarl import URL
+
+
+# serialize
+
+
+def test_pickle():
+ u1 = URL('test')
+ hash(u1)
+ v = pickle.dumps(u1)
+ u2 = pickle.loads(v)
+ assert u1._cache
+ assert not u2._cache
+ assert hash(u1) == hash(u2)
+
+
+def test_default_style_state():
+ u = URL('test')
+ hash(u)
+ u.__setstate__((None, {
+ '_val': 'test',
+ '_strict': False,
+ '_cache': {'hash': 1},
+ }))
+ assert not u._cache
+ assert u._val == 'test'
+ assert u._strict is False
diff --git a/tests/test_url.py b/tests/test_url.py
index e4b1f11..b04d6f4 100644
--- a/tests/test_url.py
+++ b/tests/test_url.py
@@ -1,8 +1,7 @@
import sys
-import pickle
import pytest
-from urllib.parse import SplitResult, urlencode
-from multidict import MultiDict, MultiDictProxy
+from urllib.parse import SplitResult
+from multidict import MultiDict
from yarl import URL
@@ -44,6 +43,11 @@ def test_origin_no_scheme():
url.origin()
+def test_drop_dots():
+ u = URL('http://example.com/path/../to')
+ assert str(u) == 'http://example.com/to'
+
+
def test_abs_cmp():
assert URL('http://example.com:8888') == URL('http://example.com:8888')
assert URL('http://example.com:8888/') == URL('http://example.com:8888/')
@@ -210,45 +214,7 @@ def test_query_string_spaces():
url = URL('http://example.com?a+b=c+d&e=f+g')
assert url.query_string == 'a b=c d&e=f g'
-
-def test_query_spaces():
- url = URL('http://example.com?a+b=c+d')
- assert url.query == MultiDict({'a b': 'c d'})
-
-
-def test_query_empty():
- url = URL('http://example.com')
- assert isinstance(url.query, MultiDictProxy)
- assert url.query == MultiDict()
-
-
-def test_query():
- url = URL('http://example.com?a=1&b=2')
- assert url.query == MultiDict([('a', '1'), ('b', '2')])
-
-
-def test_query_repeated_args():
- url = URL('http://example.com?a=1&b=2&a=3')
- assert url.query == MultiDict([('a', '1'), ('b', '2'), ('a', '3')])
-
-
-def test_query_empty_arg():
- url = URL('http://example.com?a')
- assert url.query == MultiDict([('a', '')])
-
-
-def test_query_dont_unqoute_twice():
- sample_url = 'http://base.place?' + urlencode({'a': '/////'})
- query = urlencode({'url': sample_url})
- full_url = 'http://test_url.aha?' + query
-
- url = URL(full_url)
- assert url.query['url'] == sample_url
-
-
-def test_query_nonascii():
- url = URL('http://example.com?ключ=знач')
- assert url.query == MultiDict({'ключ': 'знач'})
+# raw fragment
def test_raw_fragment_empty():
@@ -495,256 +461,47 @@ def test_div_with_colon_and_at():
assert url.raw_path == '/base/path:abc at 123'
-# comparison and hashing
-
-def test_ne_str():
- url = URL('http://example.com/')
- assert url != 'http://example.com/'
-
-
-def test_eq():
- url = URL('http://example.com/')
- assert url == URL('http://example.com/')
-
-
-def test_hash():
- assert hash(URL('http://example.com/')) == hash(URL('http://example.com/'))
-
-
-def test_hash_double_call():
- url = URL('http://example.com/')
- assert hash(url) == hash(url)
-
-
-def test_le_less():
- url1 = URL('http://example1.com/')
- url2 = URL('http://example2.com/')
-
- assert url1 <= url2
-
-
-def test_le_eq():
- url1 = URL('http://example.com/')
- url2 = URL('http://example.com/')
-
- assert url1 <= url2
-
-
-def test_le_not_implemented():
- url = URL('http://example1.com/')
-
- assert url.__le__(123) is NotImplemented
-
-
-def test_lt():
- url1 = URL('http://example1.com/')
- url2 = URL('http://example2.com/')
-
- assert url1 < url2
-
-
-def test_lt_not_implemented():
- url = URL('http://example1.com/')
-
- assert url.__lt__(123) is NotImplemented
-
-
-def test_ge_more():
- url1 = URL('http://example1.com/')
- url2 = URL('http://example2.com/')
+def test_div_with_dots():
+ url = URL('http://example.com/base') / '../path/./to'
+ assert url.raw_path == '/path/to'
- assert url2 >= url1
+# with_path
-def test_ge_eq():
- url1 = URL('http://example.com/')
- url2 = URL('http://example.com/')
- assert url2 >= url1
-
-
-def test_ge_not_implemented():
- url = URL('http://example1.com/')
-
- assert url.__ge__(123) is NotImplemented
-
-
-def test_gt():
- url1 = URL('http://example1.com/')
- url2 = URL('http://example2.com/')
-
- assert url2 > url1
-
-
-def test_gt_not_implemented():
- url = URL('http://example1.com/')
-
- assert url.__gt__(123) is NotImplemented
-
-
-# with_*
-
-
-def test_with_scheme():
- url = URL('http://example.com')
- assert str(url.with_scheme('https')) == 'https://example.com'
-
-
-def test_with_scheme_uppercased():
- url = URL('http://example.com')
- assert str(url.with_scheme('HTTPS')) == 'https://example.com'
-
-
-def test_with_scheme_for_relative_url():
- with pytest.raises(ValueError):
- URL('path/to').with_scheme('http')
-
-
-def test_with_scheme_invalid_type():
- url = URL('http://example.com')
- with pytest.raises(TypeError):
- assert str(url.with_scheme(123))
-
-
-def test_with_user():
- url = URL('http://example.com')
- assert str(url.with_user('john')) == 'http://john@example.com'
-
-
-def test_with_user_non_ascii():
+def test_with_path():
url = URL('http://example.com')
- url2 = url.with_user('вася')
- assert url2.raw_user == '%D0%B2%D0%B0%D1%81%D1%8F'
- assert url2.user == 'вася'
-
-
-def test_with_user_for_relative_url():
- with pytest.raises(ValueError):
- URL('path/to').with_user('user')
-
-
-def test_with_user_invalid_type():
- url = URL('http://example.com:123')
- with pytest.raises(TypeError):
- url.with_user(123)
-
-
-def test_with_user_None():
- url = URL('http://john@example.com')
- assert str(url.with_user(None)) == 'http://example.com'
-
-
-def test_with_user_None_when_password_present():
- url = URL('http://john:pass@example.com')
- assert str(url.with_user(None)) == 'http://example.com'
-
-
-def test_with_password():
- url = URL('http://john@example.com')
- assert str(url.with_password('pass')) == 'http://john:pass@example.com'
-
-
-def test_with_password_non_ascii():
- url = URL('http://john@example.com')
- url2 = url.with_password('пароль')
- assert url2.raw_password == '%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D1%8C'
- assert url2.password == 'пароль'
-
-
-def test_with_password_for_relative_url():
- with pytest.raises(ValueError):
- URL('path/to').with_password('pass')
-
-
-def test_with_password_None():
- url = URL('http://john:pass@example.com')
- assert str(url.with_password(None)) == 'http://john@example.com'
-
-
-def test_with_password_invalid_type():
- url = URL('http://example.com:123')
- with pytest.raises(TypeError):
- url.with_password(123)
+ assert str(url.with_path('/test')) == 'http://example.com/test'
-def test_with_password_and_empty_user():
+def test_with_path_encoded():
url = URL('http://example.com')
- with pytest.raises(ValueError):
- assert str(url.with_password('pass'))
-
-
-def test_from_str_with_host_ipv4():
- url = URL('http://host:80')
- url = url.with_host('192.168.1.1')
- assert url.raw_host == '192.168.1.1'
-
-
-def test_from_str_with_host_ipv6():
- url = URL('http://host:80')
- url = url.with_host('::1')
- assert url.raw_host == '::1'
-
-
-def test_with_host():
- url = URL('http://example.com:123')
- assert str(url.with_host('example.org')) == 'http://example.org:123'
-
-
-def test_with_host_empty():
- url = URL('http://example.com:123')
- with pytest.raises(ValueError):
- url.with_host('')
-
-
-def test_with_host_non_ascii():
- url = URL('http://example.com:123')
- url2 = url.with_host('историк.рф')
- assert url2.raw_host == 'xn--h1aagokeh.xn--p1ai'
- assert url2.host == 'историк.рф'
-
-
-def test_with_host_for_relative_url():
- with pytest.raises(ValueError):
- URL('path/to').with_host('example.com')
-
-
-def test_with_host_invalid_type():
- url = URL('http://example.com:123')
- with pytest.raises(TypeError):
- url.with_host(None)
+ assert str(url.with_path('/test',
+ encoded=True)
+ ) == 'http://example.com/test'
-def test_with_port():
+def test_with_path_dots():
url = URL('http://example.com')
- assert str(url.with_port(8888)) == 'http://example.com:8888'
-
+ assert str(url.with_path('/test/.')) == 'http://example.com/test/'
-def test_with_port_keeps_query_and_fragment():
- url = URL('http://example.com/?a=1#frag')
- assert str(url.with_port(8888)) == 'http://example.com:8888/?a=1#frag'
-
-def test_with_port_for_relative_url():
- with pytest.raises(ValueError):
- URL('path/to').with_port(1234)
+def test_with_path_relative():
+ url = URL('/path')
+ assert str(url.with_path('/new')) == '/new'
-def test_with_port_invalid_type():
- with pytest.raises(TypeError):
- URL('http://example.com').with_port('123')
+def test_with_path_query():
+ url = URL('http://example.com?a=b')
+ assert str(url.with_path('/test')) == 'http://example.com/test'
-def test_with_path():
- url = URL('http://example.com')
+def test_with_path_fragment():
+ url = URL('http://example.com#frag')
assert str(url.with_path('/test')) == 'http://example.com/test'
-def test_with_path_encoded():
- url = URL('http://example.com')
- assert str(url.with_path('/test',
- encoded=True)
- ) == 'http://example.com/test'
-
+# with_query
def test_with_query():
url = URL('http://example.com')
@@ -886,6 +643,14 @@ def test_with_query_memoryview():
url.with_query(memoryview(b'123'))
+def test_with_query_params():
+ url = URL('http://example.com/get')
+ url2 = url.with_query([('key', '1;2;3')])
+ assert str(url2) == 'http://example.com/get?key=1;2;3'
+
+
+# with_fragment
+
def test_with_fragment():
url = URL('http://example.com')
assert str(url.with_fragment('frag')) == 'http://example.com/#frag'
@@ -915,6 +680,8 @@ def test_with_fragment_bad_type():
with pytest.raises(TypeError):
url.with_fragment(123)
+# with_name
+
def test_with_name():
url = URL('http://example.com/a/b')
@@ -980,6 +747,16 @@ def test_with_name_within_colon_and_at():
url = URL('http://example.com/oldpath').with_name('path:abc at 123')
assert url.raw_path == '/path:abc at 123'
+
+def test_with_name_dot():
+ with pytest.raises(ValueError):
+ URL('http://example.com').with_name('.')
+
+
+def test_with_name_double_dot():
+ with pytest.raises(ValueError):
+ URL('http://example.com').with_name('..')
+
# is_absolute
@@ -1389,163 +1166,3 @@ def test_requoting():
u = URL('http://127.0.0.1/?next=http%3A//example.com/')
assert u.raw_query_string == 'next=http://example.com/'
assert str(u) == 'http://127.0.0.1/?next=http://example.com/'
-
-
-# query separators
-
-def test_ampersand_as_separator():
- u = URL('http://127.0.0.1/?a=1&b=2')
- assert len(u.query) == 2
-
-
-def test_ampersand_as_value():
- u = URL('http://127.0.0.1/?a=1%26b=2')
- assert len(u.query) == 1
- assert u.query['a'] == '1&b=2'
-
-
-def test_semicolon_as_separator():
- u = URL('http://127.0.0.1/?a=1;b=2')
- assert len(u.query) == 2
-
-
-def test_semicolon_as_value():
- u = URL('http://127.0.0.1/?a=1%3Bb=2')
- assert len(u.query) == 1
- assert u.query['a'] == '1;b=2'
-
-
-# serialize
-
-def test_pickle():
- u1 = URL('test')
- hash(u1)
- v = pickle.dumps(u1)
- u2 = pickle.loads(v)
- assert u1._cache
- assert not u2._cache
- assert hash(u1) == hash(u2)
-
-
-def test_default_style_state():
- u = URL('test')
- hash(u)
- u.__setstate__((None, {
- '_val': 'test',
- '_strict': False,
- '_cache': {'hash': 1},
- }))
- assert not u._cache
- assert u._val == 'test'
- assert u._strict is False
-
-
-# build classmethod
-
-def test_build_without_arguments():
- u = URL.build()
- assert str(u) == ''
-
-
-def test_build_simple():
- u = URL.build(scheme='http', host='127.0.0.1')
- assert str(u) == 'http://127.0.0.1'
-
-
-def test_build_scheme_and_host():
- with pytest.raises(ValueError):
- URL.build(host='127.0.0.1')
-
- with pytest.raises(ValueError):
- URL.build(scheme='http')
-
-
-def test_build_with_port():
- u = URL.build(scheme='http', host='127.0.0.1', port=8000)
- assert str(u) == 'http://127.0.0.1:8000'
-
-
-def test_build_with_user():
- u = URL.build(scheme='http', host='127.0.0.1', user='foo')
- assert str(u) == 'http://foo@127.0.0.1'
-
-
-def test_build_with_user_password():
- u = URL.build(scheme='http', host='127.0.0.1', user='foo', password='bar')
- assert str(u) == 'http://foo:bar@127.0.0.1'
-
-
-def test_build_with_query_and_query_string():
- with pytest.raises(ValueError):
- URL.build(
- scheme='http',
- host='127.0.0.1',
- user='foo',
- password='bar',
- port=8000,
- path='/index.html',
- query=dict(arg="value1"),
- query_string="arg=value1",
- fragment="top"
- )
-
-
-def test_build_with_all():
- u = URL.build(
- scheme='http',
- host='127.0.0.1',
- user='foo',
- password='bar',
- port=8000,
- path='/index.html',
- query_string="arg=value1",
- fragment="top"
- )
- assert str(u) == 'http://foo:bar@127.0.0.1:8000/index.html?arg=value1#top'
-
-
-def test_query_str():
- u = URL.build(
- scheme='http',
- host='127.0.0.1',
- path='/',
- query_string="arg=value1"
- )
- assert str(u) == 'http://127.0.0.1/?arg=value1'
-
-
-def test_query_dict():
- u = URL.build(
- scheme='http',
- host='127.0.0.1',
- path='/',
- query=dict(arg="value1")
- )
-
- assert str(u) == 'http://127.0.0.1/?arg=value1'
-
-
-def test_build_path_quoting():
- u = URL.build(
- scheme='http',
- host='127.0.0.1',
- path='/файл.jpg',
- query=dict(arg="Привет")
- )
-
- assert u == URL('http://127.0.0.1/файл.jpg?arg=Привет')
- assert str(u) == ('http://127.0.0.1/%D1%84%D0%B0%D0%B9%D0%BB.jpg?'
- 'arg=%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82')
-
-
-def test_build_query_quoting():
- u = URL.build(
- scheme='http',
- host='127.0.0.1',
- path='/файл.jpg',
- query="arg=Привет"
- )
-
- assert u == URL('http://127.0.0.1/файл.jpg?arg=Привет')
- assert str(u) == ('http://127.0.0.1/%D1%84%D0%B0%D0%B9%D0%BB.jpg?'
- 'arg=%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82')
diff --git a/tests/test_url_build.py b/tests/test_url_build.py
new file mode 100644
index 0000000..b1c91cc
--- /dev/null
+++ b/tests/test_url_build.py
@@ -0,0 +1,124 @@
+import pytest
+
+from yarl import URL
+
+
+# build classmethod
+
+
+def test_build_without_arguments():
+ u = URL.build()
+ assert str(u) == ''
+
+
+def test_build_simple():
+ u = URL.build(scheme='http', host='127.0.0.1')
+ assert str(u) == 'http://127.0.0.1'
+
+
+def test_build_scheme_and_host():
+ with pytest.raises(ValueError):
+ URL.build(host='127.0.0.1')
+
+ with pytest.raises(ValueError):
+ URL.build(scheme='http')
+
+
+def test_build_with_port():
+ u = URL.build(scheme='http', host='127.0.0.1', port=8000)
+ assert str(u) == 'http://127.0.0.1:8000'
+
+
+def test_build_with_user():
+ u = URL.build(scheme='http', host='127.0.0.1', user='foo')
+ assert str(u) == 'http://foo@127.0.0.1'
+
+
+def test_build_with_user_password():
+ u = URL.build(scheme='http', host='127.0.0.1', user='foo', password='bar')
+ assert str(u) == 'http://foo:bar@127.0.0.1'
+
+
+def test_build_with_query_and_query_string():
+ with pytest.raises(ValueError):
+ URL.build(
+ scheme='http',
+ host='127.0.0.1',
+ user='foo',
+ password='bar',
+ port=8000,
+ path='/index.html',
+ query=dict(arg="value1"),
+ query_string="arg=value1",
+ fragment="top"
+ )
+
+
+def test_build_with_all():
+ u = URL.build(
+ scheme='http',
+ host='127.0.0.1',
+ user='foo',
+ password='bar',
+ port=8000,
+ path='/index.html',
+ query_string="arg=value1",
+ fragment="top"
+ )
+ assert str(u) == 'http://foo:bar@127.0.0.1:8000/index.html?arg=value1#top'
+
+
+def test_query_str():
+ u = URL.build(
+ scheme='http',
+ host='127.0.0.1',
+ path='/',
+ query_string="arg=value1"
+ )
+ assert str(u) == 'http://127.0.0.1/?arg=value1'
+
+
+def test_query_dict():
+ u = URL.build(
+ scheme='http',
+ host='127.0.0.1',
+ path='/',
+ query=dict(arg="value1")
+ )
+
+ assert str(u) == 'http://127.0.0.1/?arg=value1'
+
+
+def test_build_path_quoting():
+ u = URL.build(
+ scheme='http',
+ host='127.0.0.1',
+ path='/файл.jpg',
+ query=dict(arg="Привет")
+ )
+
+ assert u == URL('http://127.0.0.1/файл.jpg?arg=Привет')
+ assert str(u) == ('http://127.0.0.1/%D1%84%D0%B0%D0%B9%D0%BB.jpg?'
+ 'arg=%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82')
+
+
+def test_build_query_quoting():
+ u = URL.build(
+ scheme='http',
+ host='127.0.0.1',
+ path='/файл.jpg',
+ query="arg=Привет"
+ )
+
+ assert u == URL('http://127.0.0.1/файл.jpg?arg=Привет')
+ assert str(u) == ('http://127.0.0.1/%D1%84%D0%B0%D0%B9%D0%BB.jpg?'
+ 'arg=%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82')
+
+
+def test_build_drop_dots():
+ u = URL.build(
+ scheme='http',
+ host='example.com',
+ path='/path/../to',
+ )
+ assert str(u) == 'http://example.com/to'
diff --git a/tests/test_url_cmp_and_hash.py b/tests/test_url_cmp_and_hash.py
new file mode 100644
index 0000000..71742d3
--- /dev/null
+++ b/tests/test_url_cmp_and_hash.py
@@ -0,0 +1,89 @@
+from yarl import URL
+
+
+# comparison and hashing
+
+
+def test_ne_str():
+ url = URL('http://example.com/')
+ assert url != 'http://example.com/'
+
+
+def test_eq():
+ url = URL('http://example.com/')
+ assert url == URL('http://example.com/')
+
+
+def test_hash():
+ assert hash(URL('http://example.com/')) == hash(URL('http://example.com/'))
+
+
+def test_hash_double_call():
+ url = URL('http://example.com/')
+ assert hash(url) == hash(url)
+
+
+def test_le_less():
+ url1 = URL('http://example1.com/')
+ url2 = URL('http://example2.com/')
+
+ assert url1 <= url2
+
+
+def test_le_eq():
+ url1 = URL('http://example.com/')
+ url2 = URL('http://example.com/')
+
+ assert url1 <= url2
+
+
+def test_le_not_implemented():
+ url = URL('http://example1.com/')
+
+ assert url.__le__(123) is NotImplemented
+
+
+def test_lt():
+ url1 = URL('http://example1.com/')
+ url2 = URL('http://example2.com/')
+
+ assert url1 < url2
+
+
+def test_lt_not_implemented():
+ url = URL('http://example1.com/')
+
+ assert url.__lt__(123) is NotImplemented
+
+
+def test_ge_more():
+ url1 = URL('http://example1.com/')
+ url2 = URL('http://example2.com/')
+
+ assert url2 >= url1
+
+
+def test_ge_eq():
+ url1 = URL('http://example.com/')
+ url2 = URL('http://example.com/')
+
+ assert url2 >= url1
+
+
+def test_ge_not_implemented():
+ url = URL('http://example1.com/')
+
+ assert url.__ge__(123) is NotImplemented
+
+
+def test_gt():
+ url1 = URL('http://example1.com/')
+ url2 = URL('http://example2.com/')
+
+ assert url2 > url1
+
+
+def test_gt_not_implemented():
+ url = URL('http://example1.com/')
+
+ assert url.__gt__(123) is NotImplemented
diff --git a/tests/test_url_query.py b/tests/test_url_query.py
new file mode 100644
index 0000000..1111d06
--- /dev/null
+++ b/tests/test_url_query.py
@@ -0,0 +1,72 @@
+from urllib.parse import urlencode
+
+from multidict import MultiDict, MultiDictProxy
+
+
+from yarl import URL
+
+# query
+
+
+def test_query_spaces():
+ url = URL('http://example.com?a+b=c+d')
+ assert url.query == MultiDict({'a b': 'c d'})
+
+
+def test_query_empty():
+ url = URL('http://example.com')
+ assert isinstance(url.query, MultiDictProxy)
+ assert url.query == MultiDict()
+
+
+def test_query():
+ url = URL('http://example.com?a=1&b=2')
+ assert url.query == MultiDict([('a', '1'), ('b', '2')])
+
+
+def test_query_repeated_args():
+ url = URL('http://example.com?a=1&b=2&a=3')
... 415 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/yarl.git
More information about the Python-modules-commits
mailing list