From 2dcfd09cc29c7fe6929503e6c83c75a0cb83d66f Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Mon, 19 Nov 2018 04:36:46 -0800 Subject: [PATCH] Scheduled monthly dependency update for November (#210) * Update pytest from 3.8.1 to 3.9.3 * Update pytest from 3.8.1 to 3.9.3 * Update pytest-cov from 2.5.1 to 2.6.0 * Update pytest-cov from 2.5.1 to 2.6.0 * Update aiohttp-jinja2 from 1.0.0 to 1.1.0 * Update aiohttp-jinja2 from 1.0.0 to 1.1.0 * Update aiohttp-session from 2.5.1 to 2.7.0 * Update aiohttp-session from 2.6.0 to 2.7.0 * Update aiohttp-session from 2.6.0 to 2.7.0 * Update sqlalchemy from 1.2.11 to 1.2.13 * Update sqlalchemy from 1.2.11 to 1.2.13 * Update flake8 from 3.5.0 to 3.6.0 * Update pycodestyle from 2.3.1 to 2.4.0 * Update pytest-isort from 0.2.0 to 0.2.1 * Update pytest-xdist from 1.23.0 to 1.24.0 * Update sphinx from 1.7.8 to 1.8.1 * fix linting * fix deprecation warnings * fixing tests * fix release date * fix coverage combine --- HISTORY.rst | 2 +- Makefile | 2 +- aiohttp_devtools/cli.py | 8 +++---- aiohttp_devtools/logs.py | 2 +- aiohttp_devtools/runserver/config.py | 4 ++-- aiohttp_devtools/runserver/log_handlers.py | 4 ++-- aiohttp_devtools/start/main.py | 14 +++++------ aiohttp_devtools/start/template/app/views.py | 4 ++-- .../start/template/requirements.txt | 10 ++++---- setup.cfg | 4 ++++ tests/requirements.txt | 23 ++++++++++--------- tests/test_cli.py | 4 ++-- tests/test_runserver_main.py | 16 ++++++------- tests/test_runserver_serve.py | 8 +++---- tests/test_runserver_watch.py | 4 ++-- tests/test_serve.py | 12 +++++----- tests/test_start.py | 12 +++++----- 17 files changed, 69 insertions(+), 64 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 84e8b065..e987d050 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,7 +3,7 @@ History ------- -0.10.4 (2018-11-18) +0.10.4 (2018-11-19) ------------------- * fix conflict with click checks that prevented the ``--root`` flag working properly, #206 * uprev dependencies diff --git a/Makefile b/Makefile index ff820ba8..7dd8619e 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ lint: .PHONY: test test: - pytest --cov=aiohttp_devtools --boxed --duration 5 && coverage combine + pytest --cov=aiohttp_devtools --boxed --duration 5 && (coverage combine || test 0) .PHONY: testcov testfast: diff --git a/aiohttp_devtools/cli.py b/aiohttp_devtools/cli.py index 5adf332a..29f8b4ea 100644 --- a/aiohttp_devtools/cli.py +++ b/aiohttp_devtools/cli.py @@ -107,10 +107,10 @@ def get_metavar(self, param): DECISIONS = [ - ('template_engine', TemplateChoice), - ('session', SessionChoices), - ('database', DatabaseChoice), - ('example', ExampleChoice), + ('template_engine', TemplateChoice), + ('session', SessionChoices), + ('database', DatabaseChoice), + ('example', ExampleChoice), ] diff --git a/aiohttp_devtools/logs.py b/aiohttp_devtools/logs.py index f426abed..c971d093 100644 --- a/aiohttp_devtools/logs.py +++ b/aiohttp_devtools/logs.py @@ -24,7 +24,7 @@ def get_log_format(record): class DefaultHandler(logging.Handler): def emit(self, record): log_entry = self.format(record) - m = re.match('^(\[.*?\])', log_entry) + m = re.match(r'^(\[.*?\])', log_entry) if m: time = click.style(m.groups()[0], fg='magenta') msg = click.style(log_entry[m.end():], **get_log_format(record)) diff --git a/aiohttp_devtools/runserver/config.py b/aiohttp_devtools/runserver/config.py index be360f63..5b7e506f 100644 --- a/aiohttp_devtools/runserver/config.py +++ b/aiohttp_devtools/runserver/config.py @@ -11,8 +11,8 @@ from ..logs import rs_dft_logger as logger STD_FILE_NAMES = [ - re.compile('main\.py'), - re.compile('app\.py'), + re.compile(r'main\.py'), + re.compile(r'app\.py'), ] diff --git a/aiohttp_devtools/runserver/log_handlers.py b/aiohttp_devtools/runserver/log_handlers.py index dc174be8..3e93d692 100644 --- a/aiohttp_devtools/runserver/log_handlers.py +++ b/aiohttp_devtools/runserver/log_handlers.py @@ -11,7 +11,7 @@ class AuxiliaryHandler(logging.Handler): def emit(self, record): log_entry = self.format(record) - m = re.match('^(\[.*?\] )', log_entry) + m = re.match(r'^(\[.*?\] )', log_entry) time = click.style(m.groups()[0], fg='magenta') msg = log_entry[m.end():] if record.levelno in {logging.INFO, logging.DEBUG} and msg.startswith('>'): @@ -33,7 +33,7 @@ class AiohttpAccessHandler(logging.Handler): def emit(self, record): log_entry = self.format(record) - m = re.match('^(\[.*?\] )', log_entry) + m = re.match(r'^(\[.*?\] )', log_entry) time = click.style(m.groups()[0], fg='magenta') msg = log_entry[m.end():] try: diff --git a/aiohttp_devtools/start/main.py b/aiohttp_devtools/start/main.py index 16a3dccf..80084220 100644 --- a/aiohttp_devtools/start/main.py +++ b/aiohttp_devtools/start/main.py @@ -15,14 +15,14 @@ FILES_REGEXES = { '.py': [ - ('^ *# *\n', '', re.M), # blank comments - ('\n *# *$', '', 0), # blank comment at end of fie - ('\n{4,}', '\n\n\n', 0), # more than 2 empty lines - ('^\s+', '', 0), # leading new lines + (r'^ *# *\n', '', re.M), # blank comments + (r'\n *# *$', '', 0), # blank comment at end of fie + (r'\n{4,}', '\n\n\n', 0), # more than 2 empty lines + (r'^\s+', '', 0), # leading new lines ], '.sh': [ - ('^ *# *\n', '', re.M), # blank comments - ('\n *# *$', '', 0), # blank comment at end of fie + (r'^ *# *\n', '', re.M), # blank comments + (r'\n *# *$', '', 0), # blank comment at end of fie ], } @@ -126,7 +126,7 @@ def __init__(self, *, logger.info('config:\n%s', '\n'.join(' {}: {}'.format(*c) for c in display_config)) self.ctx = { 'name': name, - 'clean_name': re.sub('[^\w_]', '', re.sub('[.-]', '_', name)), + 'clean_name': re.sub(r'[^\w_]', '', re.sub(r'[.-]', '_', name)), 'cookie_secret_key': base64.urlsafe_b64encode(os.urandom(32)).decode(), 'template_engine': self._choice_context(template_engine, TemplateChoice), 'session': self._choice_context(session, SessionChoices), diff --git a/aiohttp_devtools/start/template/app/views.py b/aiohttp_devtools/start/template/app/views.py index 5bb0f3a1..f1303022 100644 --- a/aiohttp_devtools/start/template/app/views.py +++ b/aiohttp_devtools/start/template/app/views.py @@ -208,14 +208,14 @@ async def message_data(request): username, ts, message = line.split('|', 2) # parse the datetime string and render it in a more readable format. ts = '{:%Y-%m-%d %H:%M:%S}'.format(datetime.strptime(ts, '%Y-%m-%dT%H:%M:%S.%f')) - messages.append({'username': username, 'timestamp': ts, 'message': message}) + messages.append({'username': username, 'timestamp': ts, 'message': message}) messages.reverse() # {% elif database.is_pg_sqlalchemy %} async with request.app['pg_engine'].acquire() as conn: async for row in conn.execute(sa_messages.select().order_by(sa_messages.c.timestamp.desc())): ts = '{:%Y-%m-%d %H:%M:%S}'.format(row.timestamp) - messages.append({'username': row.username, 'timestamp': ts, 'message': row.message}) + messages.append({'username': row.username, 'timestamp': ts, 'message': row.message}) # {% endif %} return json_response(messages) # {% endif %} diff --git a/aiohttp_devtools/start/template/requirements.txt b/aiohttp_devtools/start/template/requirements.txt index 7bf13914..f77085bb 100644 --- a/aiohttp_devtools/start/template/requirements.txt +++ b/aiohttp_devtools/start/template/requirements.txt @@ -2,19 +2,19 @@ # you will need to install these requirements with `pip install -r requirements.txt` aiohttp==3.4.4 -pytest==3.8.1 +pytest==3.9.3 pytest-aiohttp==0.3.0 -pytest-cov==2.5.1 +pytest-cov==2.6.0 # {% if template_engine.is_jinja %} -aiohttp-jinja2==1.0.0 +aiohttp-jinja2==1.1.0 # {% endif %} # {% if session.is_secure %} -aiohttp-session[secure]==2.5.1 +aiohttp-session[secure]==2.7.0 # {% endif %} # {% if database.is_pg_sqlalchemy %} aiopg==0.15.0 -SQLAlchemy==1.2.11 +SQLAlchemy==1.2.13 # {% endif %} diff --git a/setup.cfg b/setup.cfg index ee92330f..2b68a626 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,11 +5,15 @@ timeout = 10 isort_ignore = aiohttp_devtools/start/template/*.py tests/test_runserver_main.py +filterwarnings = + ignore::DeprecationWarning:aiohttp_debugtoolbar.tbtools.tbtools [flake8] max-line-length = 120 max-complexity = 10 exclude = aiohttp_devtools/start/template +# remove E252 once https://github.com/PyCQA/pycodestyle/issues/753 is released +ignore = E252, W504 [bdist_wheel] python-tag = py35.py36 diff --git a/tests/requirements.txt b/tests/requirements.txt index 48cdac94..4243dd54 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,23 +1,24 @@ +click==7.0.0 coverage==4.5.1 docutils==0.14 -flake8==3.5.0 +flake8==3.6.0 grablib==0.6.1 # pyup: ignore (last version which is compatible with python 3.5) -pycodestyle==2.3.1 +pycodestyle==2.4.0 pyflakes==2.0.0 -pytest==3.8.1 +pytest==3.9.3 pytest-aiohttp==0.3.0 -pytest-cov==2.5.1 -pytest-isort==0.2.0 +pytest-cov==2.6.0 +pytest-isort==0.2.1 pytest-mock==1.10.0 pytest-sugar==0.9.1 pytest-timeout==1.3.2 pytest-toolbox==0.4 -pytest-xdist==1.23.0 -Sphinx==1.7.8 +pytest-xdist==1.24.0 +Sphinx==1.8.1 # required to run "start" apps -aiohttp-jinja2==1.0.0 -aiohttp-session[secure]==2.6.0 -aiohttp-session[aioredis]==2.6.0 +aiohttp-jinja2==1.1.0 +aiohttp-session[secure]==2.7.0 +aiohttp-session[aioredis]==2.7.0 aiopg==0.15.0 -SQLAlchemy==1.2.11 +SQLAlchemy==1.2.13 diff --git a/tests/test_cli.py b/tests/test_cli.py index 11561e9e..d18df45a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -30,7 +30,7 @@ def test_serve_no_args(): runner = CliRunner() result = runner.invoke(cli, ['serve']) assert result.exit_code == 2 - assert 'error: missing argument "path"' in result.output.lower() + assert 'Error: Missing argument "PATH"' in result.output def test_runserver(mocker): @@ -131,7 +131,7 @@ def test_start_no_args(): runner = CliRunner() result = runner.invoke(cli, ['start']) assert result.exit_code == 2 - assert 'error: missing argument "path"' in result.output.lower() + assert 'Error: Missing argument "PATH"' in result.output def test_start_help(): diff --git a/tests/test_runserver_main.py b/tests/test_runserver_main.py index ba178593..51b1b989 100644 --- a/tests/test_runserver_main.py +++ b/tests/test_runserver_main.py @@ -118,34 +118,34 @@ def kill_parent_soon(pid): @if_boxed @slow -def test_run_app(loop, unused_port): +def test_run_app(loop, aiohttp_unused_port): app = Application() - port = unused_port() + port = aiohttp_unused_port() Process(target=kill_parent_soon, args=(os.getpid(),)).start() run_app(app, port, loop) @if_boxed -async def test_run_app_test_client(tmpworkdir, test_client): +async def test_run_app_aiohttp_client(tmpworkdir, aiohttp_client): mktree(tmpworkdir, SIMPLE_APP) config = Config(app_path='app.py') app_factory = config.import_app_factory() app = app_factory() modify_main_app(app, config) assert isinstance(app, aiohttp.web.Application) - cli = await test_client(app) + cli = await aiohttp_client(app) r = await cli.get('/') assert r.status == 200 text = await r.text() assert text == 'hello world' -async def test_aux_app(tmpworkdir, test_client): +async def test_aux_app(tmpworkdir, aiohttp_client): mktree(tmpworkdir, { 'test.txt': 'test value', }) app = create_auxiliary_app(static_path='.') - cli = await test_client(app) + cli = await aiohttp_client(app) r = await cli.get('/test.txt') assert r.status == 200 text = await r.text() @@ -189,9 +189,9 @@ async def hello(request): @pytest.yield_fixture -def aux_cli(test_client, loop): +def aux_cli(aiohttp_client, loop): app = create_auxiliary_app(static_path='.') - cli = loop.run_until_complete(test_client(app)) + cli = loop.run_until_complete(aiohttp_client(app)) yield cli loop.run_until_complete(cli.close()) diff --git a/tests/test_runserver_serve.py b/tests/test_runserver_serve.py index cb1a3beb..1b0736da 100644 --- a/tests/test_runserver_serve.py +++ b/tests/test_runserver_serve.py @@ -21,14 +21,14 @@ ) -async def test_check_port_open(unused_port, loop): - port = unused_port() +async def test_check_port_open(aiohttp_unused_port, loop): + port = aiohttp_unused_port() await check_port_open(port, loop, 0.001) @non_windows_test # FIXME: probably needs some sock options -async def test_check_port_not_open(unused_port, loop): - port = unused_port() +async def test_check_port_not_open(aiohttp_unused_port, loop): + port = aiohttp_unused_port() with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: sock.bind(('0.0.0.0', port)) with pytest.raises(AiohttpDevException): diff --git a/tests/test_runserver_watch.py b/tests/test_runserver_watch.py index c858f738..93257005 100644 --- a/tests/test_runserver_watch.py +++ b/tests/test_runserver_watch.py @@ -81,11 +81,11 @@ async def test_python_no_server(loop, mocker): await app_task._session.close() -async def test_reload_server_running(loop, test_client, mocker): +async def test_reload_server_running(loop, aiohttp_client, mocker): app = Application() app['websockets'] = [None] mock_src_reload = mocker.patch('aiohttp_devtools.runserver.watch.src_reload', return_value=create_future()) - cli = await test_client(app) + cli = await aiohttp_client(app) config = MagicMock() config.main_port = cli.server.port diff --git a/tests/test_serve.py b/tests/test_serve.py index a4ed72d9..edb8b948 100644 --- a/tests/test_serve.py +++ b/tests/test_serve.py @@ -7,10 +7,10 @@ @pytest.yield_fixture -def cli(loop, tmpworkdir, test_client): +def cli(loop, tmpworkdir, aiohttp_client): asyncio.set_event_loop(loop) app, _, _ = serve_static(static_path=str(tmpworkdir), livereload=False) - yield loop.run_until_complete(test_client(app)) + yield loop.run_until_complete(aiohttp_client(app)) async def test_simple_serve(cli, tmpworkdir): @@ -32,10 +32,10 @@ async def test_file_missing(cli): assert '404: Not Found\n' in text -async def test_html_file_livereload(loop, test_client, tmpworkdir): +async def test_html_file_livereload(loop, aiohttp_client, tmpworkdir): app, port, _ = serve_static(static_path=str(tmpworkdir), livereload=True) assert port == 8000 - cli = await test_client(app) + cli = await aiohttp_client(app) mktree(tmpworkdir, { 'foo.html': '

hi

', }) @@ -51,10 +51,10 @@ async def test_html_file_livereload(loop, test_client, tmpworkdir): assert text.startswith('(function e(t,n,r){') -async def test_serve_index(loop, test_client, tmpworkdir): +async def test_serve_index(loop, aiohttp_client, tmpworkdir): app, port, _ = serve_static(static_path=str(tmpworkdir), livereload=False) assert port == 8000 - cli = await test_client(app) + cli = await aiohttp_client(app) mktree(tmpworkdir, { 'index.html': '

hello index

', }) diff --git a/tests/test_start.py b/tests/test_start.py index 72e32ec1..653a1319 100644 --- a/tests/test_start.py +++ b/tests/test_start.py @@ -52,7 +52,7 @@ def test_start_simple(tmpdir, smart_caplog): @if_boxed -async def test_start_other_dir(tmpdir, loop, test_client, smart_caplog): +async def test_start_other_dir(tmpdir, loop, aiohttp_client, smart_caplog): StartProject(path=str(tmpdir.join('the-path')), name='foobar', database=DatabaseChoice.NONE) assert {p.basename for p in tmpdir.listdir()} == {'the-path'} assert {p.basename for p in tmpdir.join('the-path').listdir()} == { @@ -79,7 +79,7 @@ async def test_start_other_dir(tmpdir, loop, test_client, smart_caplog): modify_main_app(app, config) assert isinstance(app, aiohttp.web.Application) - cli = await test_client(app) + cli = await aiohttp_client(app) r = await cli.get('/') assert r.status == 200 text = await r.text() @@ -103,7 +103,7 @@ def test_conflicting_file(tmpdir): enum_choices(DatabaseChoice), enum_choices(ExampleChoice), )) -async def test_all_options(tmpdir, test_client, loop, template_engine, session, database, example): +async def test_all_options(tmpdir, aiohttp_client, loop, template_engine, session, database, example): StartProject( path=str(tmpdir), name='foobar', @@ -123,7 +123,7 @@ async def test_all_options(tmpdir, test_client, loop, template_engine, session, app_factory = config.import_app_factory() app = await app_factory() modify_main_app(app, config) - cli = await test_client(app) + cli = await aiohttp_client(app) r = await cli.get('/') assert r.status == 200 text = await r.text() @@ -132,7 +132,7 @@ async def test_all_options(tmpdir, test_client, loop, template_engine, session, @if_boxed @slow -async def test_db_creation(tmpdir, test_client, loop): +async def test_db_creation(tmpdir, aiohttp_client, loop): StartProject( path=str(tmpdir), name='foobar postgres test', @@ -162,7 +162,7 @@ async def test_db_creation(tmpdir, test_client, loop): app_factory = config.import_app_factory() app = await app_factory() modify_main_app(app, config) - cli = await test_client(app) + cli = await aiohttp_client(app) r = await cli.get('/') assert r.status == 200 text = await r.text()