Skip to content

Commit

Permalink
fix tests for aiohttp 1.0.x and do not run tests on "master" branch.
Browse files Browse the repository at this point in the history
py3.4 is not longer supported in aiohttp in future version 3.x.x(currently on branch master)

Signed-off-by: Pawel Nuckowski <[email protected]>
  • Loading branch information
pnuckowski committed Dec 19, 2017
1 parent 4d94c14 commit e7b97be
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ matrix:
- python: 3.4
env: TOXENV=py34-aiohttp21
- python: 3.4
env: TOXENV=py34-aiohttpmaster
env: TOXENV=py34-aiohttp22
- python: 3.4
env: TOXENV=py34-aiohttp23

- python: 3.5
env: TOXENV=py35-aiohttp10
Expand All @@ -31,7 +33,11 @@ matrix:
- python: 3.5
env: TOXENV=py35-aiohttp21
- python: 3.5
env: TOXENV=py35-aiohttpmaster
env: TOXENV=py35-aiohttp22
- python: 3.5
env: TOXENV=py35-aiohttp23
# - python: 3.5
# env: TOXENV=py35-aiohttpmaster

- python: 3.5
env: TOXENV=flake8
Expand Down
11 changes: 8 additions & 3 deletions aioresponses/compat.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# -*- coding: utf-8 -*-
from aiohttp import __version__ as aiohttp_version
from typing import Optional
from urllib.parse import urlsplit, urlencode, SplitResult, urlunsplit

try:
from yarl import URL
__yarl_available = True
print(aiohttp_version)
if aiohttp_version.split('.')[:2] == ['1', '0']:
# yarl was introduced in version 1.1
raise ImportError
yarl_available = True
except ImportError:
class URL(str):
pass
__yarl_available = False
yarl_available = False


__all__ = ['URL', 'merge_url_params']
Expand Down Expand Up @@ -48,7 +53,7 @@ def _yarl_merge_url_params(url: str, params: Optional[dict]) -> str:
return str(url.with_query(params))


if __yarl_available:
if yarl_available:
merge_url_params = _yarl_merge_url_params
else:
merge_url_params = _vanilla_merge_url_params
5 changes: 2 additions & 3 deletions tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ddt import ddt, data
from aioresponses.compat import (
_vanilla_merge_url_params, _yarl_merge_url_params, URL
_vanilla_merge_url_params, _yarl_merge_url_params, yarl_available
)


Expand All @@ -13,10 +13,9 @@ class CompatTestCase(TestCase):
def setUp(self):
self.url_with_parameters = 'http://example.com/api?foo=bar#fragment'
self.url_without_parameters = 'http://example.com/api?#fragment'
self.yarn_available = not isinstance(URL, str)

def _get_merge_functions(self):
if self.yarn_available:
if yarl_available:
return {
_vanilla_merge_url_params,
_yarl_merge_url_params
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
envlist =
flake8,
coverage,
{py34,py35}-aiohttp{10,11,12,13,20,21,22,master}
py34-aiohttp{10,11,12,13,20,21,22,23}
py35-aiohttp{10,11,12,13,20,21,22,23}
skipsdist=True

[testenv:flake8]
Expand All @@ -23,6 +24,7 @@ deps =
aiohttp20: aiohttp>=2.0,<2.1
aiohttp21: aiohttp>=2.1,<2.2
aiohttp22: aiohttp>=2.2,<2.3
aiohttp23: aiohttp>=2.3,<2.4
aiohttpmaster: https://github.com/KeepSafe/aiohttp/archive/master.tar.gz
-r{toxinidir}/requirements-dev.txt

Expand Down

0 comments on commit e7b97be

Please sign in to comment.