Skip to content

Commit

Permalink
Update setup
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzheng committed Jun 6, 2018
1 parent 9147191 commit 175f4bd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -24,6 +23,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -37,6 +37,7 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
textcov/
.tox/
.coverage
.coverage.*
Expand All @@ -45,7 +46,7 @@ nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache
.pytest_cache/

# Translations
*.mo
Expand All @@ -54,6 +55,7 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
Expand All @@ -80,13 +82,14 @@ celerybeat-schedule
# SageMath parsed files
*.sage.py

# dotenv
# Environments
.env

# virtualenv
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
Expand Down
12 changes: 7 additions & 5 deletions aiohttp_requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def __getattr__(self, attr):
@functools.wraps(self.session._request)
def session_request(*args, **kwargs):
"""
This ensures `self.session` is always called where it can check the session/loop state so can't use functools.partials
as monkeypatch seems to do something weird where __getattr__ is only called once for each attribute after patch is undone
This ensures `self.session` is always called where it can check the session/loop state so can't use
functools.partials as monkeypatch seems to do something weird where __getattr__ is only called once for
each attribute after patch is undone
"""
return self.session._request(attr.upper(), *args, **kwargs)

Expand All @@ -44,10 +45,11 @@ def close(self):
"""
Close aiohttp.ClientSession.
This is useful to be called manually in tests if each test when each test uses a new loop. After close, new requests will
automatically create a new session.
This is useful to be called manually in tests if each test when each test uses a new loop. After close, new
requests will automatically create a new session.
Note: We need a sync version for `__del__` and `aiohttp.ClientSession.close()` is async even though it doesn't have to be.
Note: We need a sync version for `__del__` and `aiohttp.ClientSession.close()` is async even though it doesn't
have to be.
"""
if self._session:
if not self._session.closed:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
include_package_data=True,

python_requires='>=3.5',
setup_requires=['setuptools-git'],
setup_requires=['setuptools-git', 'wheel'],

classifiers=[
'Development Status :: 5 - Production/Stable',
Expand Down
23 changes: 13 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[tox]
envlist = test
envlist = cover, style

[testenv]
# Consolidate all deps here instead of separately in test/style/cover so we
# have a single env to work with, which makes debugging easier (like which env?).
# Not as clean but easier to work with during development, which is better.
deps =
flake8
aioresponses
flake8
mock
pytest
pytest-aiohttp
pytest-xdist
pytest-cov
sphinx!=1.2b2
pytest-fixtures
pytest-xdist
sphinx
install_command =
pip install -U {packages}
recreate = False
Expand All @@ -24,24 +25,26 @@ setenv =
PIP_DEFAULT_TIMEOUT=60
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
basepython = python3
envdir = {toxworkdir}/aiohttp-requests
envdir = {homedir}/.virtualenvs/aiohttp-requests

[testenv:test]
commands =
py.test {env:PYTESTARGS:}
pytest {env:PYTESTARGS:}

[testenv:style]
commands =
flake8 --config tox.ini

[testenv:cover]
commands =
py.test {env:PYTESTARGS:} --cov . --cov-report=xml --cov-report=html --cov-report=term --cov-fail-under=90
pytest {env:PYTESTARGS:} --cov . --cov-report=xml --cov-report=html --cov-report=term --cov-report=annotate:textcov \
--cov-fail-under=80

[flake8]
exclude = .git,.tox,.eggs,__pycache__,docs,build,dist
ignore = E111,E121,W292,E123,E226
max-line-length = 140
max-line-length = 120

[pytest]
addopts = -n 4
# Uncomment to enable concurrency for pytest
#[pytest]
#addopts = -n 4

0 comments on commit 175f4bd

Please sign in to comment.