Skip to content

Commit

Permalink
Merge pull request #5366 from hypothesis/remove-unused-py-deps
Browse files Browse the repository at this point in the history
Remove unused requests-aws4auth and certifi dependencies
  • Loading branch information
Hannah Stepanek committed Oct 11, 2018
2 parents ed5c783 + c6e65e9 commit cc0d6da
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion h/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def configure(environ=None, settings=None):

# Add ES logging filter to filter out ReadTimeout warnings
es_logger = logging.getLogger('elasticsearch')
es_logger.addFilter(ExceptionFilter((("ReadTimeout", "WARNING"),)))
es_logger.addFilter(ExceptionFilter((("ReadTimeoutError", "WARNING"),)))

return Configurator(settings=settings)

Expand Down
2 changes: 0 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ backports.functools_lru_cache
bcrypt
bleach >= 2.0
celery >= 4.2.1
certifi
cffi
click
deform < 1.0
Expand Down Expand Up @@ -39,7 +38,6 @@ pyramid_tm
python-dateutil
python-slugify < 1.2.0
raven
requests-aws4auth >= 0.9
statsd
transaction
venusian
Expand Down
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ bcrypt==3.1.3
billiard==3.5.0.3 # via celery
bleach==2.1.3
celery==4.2.1
certifi==2016.2.28
cffi==1.7.0
chameleon==2.24 # via deform
click==6.6
Expand Down Expand Up @@ -62,9 +61,7 @@ pytz==2016.6.1 # via celery
raven==6.0.0
repoze.lru==0.6 # via pyramid
repoze.sendmail==4.3 # via pyramid-mailer
requests-aws4auth==0.9
requests==2.13.0 # via requests-aws4auth
six==1.10.0 # via bcrypt, bleach, elasticsearch-dsl, python-dateutil
six==1.10.0 # via bcrypt, bleach, elasticsearch-dsl, html5lib, python-dateutil
sqlalchemy==1.1.4
statsd==3.2.1
transaction==2.1.2
Expand All @@ -73,6 +70,7 @@ unidecode==0.4.19 # via python-slugify
urllib3==1.22 # via elasticsearch
venusian==1.0
vine==1.1.4 # via amqp
webencodings==0.5.1 # via html5lib
webob==1.6.1 # via pyramid
ws4py==0.4.2
wsaccel==0.6.2
Expand Down
32 changes: 18 additions & 14 deletions tests/h/util/test_logging_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,51 @@

import pytest
import logging
from requests.exceptions import ReadTimeout
from urllib3.exceptions import ReadTimeoutError
from h.util.logging_filters import ExceptionFilter


class TestExceptionFilter(object):

def test_raises_if_invalid_level_name(self):
with pytest.raises(ValueError):
ExceptionFilter((("ReadTimeout", "WARNI"),))
ExceptionFilter((("ReadTimeoutError", "WARNI"),))

def test_specify_level_as_int(self, logger):
ExceptionFilter((("ReadTimeout", logging.WARNING),))
ExceptionFilter((("ReadTimeoutError", logging.WARNING),))

def test_does_not_log_specified_exceptions(self, logger):
def test_does_not_log_specified_exceptions(self, logger, read_timeout_exception):
try:
raise ReadTimeout("this is a test read timeout error")
except ReadTimeout:
raise read_timeout_exception
except ReadTimeoutError:
logger.warning("warning", exc_info=True)
assert not logger.handlers[0].handler_called, "Didn't filter out log message when it should have!!"

def test_does_log_if_log_level_mismatch(self, logger):
def test_does_log_if_log_level_mismatch(self, logger, read_timeout_exception):
try:
raise ReadTimeout("this is a test read timeout error")
except ReadTimeout:
raise read_timeout_exception
except ReadTimeoutError:
logger.critical("critical", exc_info=True)
assert logger.handlers[0].handler_called, "Filtered out log message when it shouldn't have!!"

def test_does_log_if_exception_mismatch(self, logger):
try:
raise Exception("this is a test read timeout error")
raise Exception("Not a read timeout")
except Exception:
logger.warning("warning", exc_info=True)
assert logger.handlers[0].handler_called, "Filtered out log message when it shouldn't have!!"

def test_does_log_if_no_exc_info_is_recorded(self, logger):
def test_does_log_if_no_exc_info_is_recorded(self, logger, read_timeout_exception):
try:
raise ReadTimeout("this is a test read timeout error")
except ReadTimeout:
raise read_timeout_exception
except ReadTimeoutError:
logger.warning("warning")
assert logger.handlers[0].handler_called, "Filtered out log message when it shouldn't have!!"

@pytest.fixture
def read_timeout_exception(self):
return ReadTimeoutError(pool=None, url="https://example.com", message="Test exception")


@pytest.fixture
def logger():
Expand All @@ -55,5 +59,5 @@ def emit(self, record):

log = logging.Logger('test_logger')
log.addHandler(TestHandler())
log.addFilter(ExceptionFilter((("ReadTimeout", "WARNING"),)))
log.addFilter(ExceptionFilter((("ReadTimeoutError", "WARNING"),)))
return log

0 comments on commit cc0d6da

Please sign in to comment.