Skip to content

Commit 4358c3e

Browse files
authored
Update pytest version (#29)
1 parent f99127d commit 4358c3e

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Flask
55
sanic; python_version >= '3.5'
66
aiohttp; python_version >= '3.5'
77
sonic182-json-validator==0.0.12
8-
pytest==3.2.2
8+
pytest==3.6.2
99
pytest-cov==2.5.1
1010
pytest-mock==1.6.3
1111
pylint

tests/test_falcon_logging.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
)
1414
from tests.util import (
1515
check_log_record,
16-
config_root_logger,
1716
enable_sensitive_fields_logging,
1817
config_logger
1918
)
@@ -79,7 +78,7 @@ def test_falcon_request_logs_user(user):
7978

8079

8180
def _check_falcon_request_log(app, headers, expected):
82-
_, stream = config_root_logger('cf.falcon.logger')
81+
_, stream = config_logger('cf.falcon.logger')
8382

8483
client = testing.TestClient(app)
8584
_check_expected_response(

tests/test_flask_logging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tests.util import (
1111
check_log_record,
1212
enable_sensitive_fields_logging,
13-
config_root_logger,
13+
config_logger,
1414
)
1515

1616

@@ -47,7 +47,7 @@ def _root():
4747
return Response('ok', mimetype='text/plain')
4848

4949
_set_up_flask_logging(app)
50-
_, stream = config_root_logger('cf.flask.logger')
50+
_, stream = config_logger('cf.flask.logger')
5151

5252
client = app.test_client()
5353
_check_expected_response(client.get('/test/path', headers=headers))
@@ -77,7 +77,7 @@ def _user_logging(headers, extra, expected):
7777

7878
@app.route('/test/user/logging')
7979
def _logging_correlation_id_route():
80-
logger, stream = config_root_logger('user.logging')
80+
logger, stream = config_logger('user.logging')
8181
logger.info('in route headers', extra=extra)
8282
assert check_log_record(stream, JOB_LOG_SCHEMA, expected) == {}
8383
return Response('ok')

tests/test_job_logging.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from json_validator.validator import JsonValidator
99
from sap import cf_logging
1010
from tests.log_schemas import JOB_LOG_SCHEMA
11-
from tests.util import config_root_logger
11+
from tests.util import config_logger
1212

1313
# pylint: disable=protected-access
1414

@@ -22,7 +22,7 @@ def before_each():
2222
def test_log_in_expected_format():
2323
""" Test the cf_logger as a standalone """
2424
cf_logging.init(level=logging.DEBUG)
25-
logger, stream = config_root_logger('cli.test')
25+
logger, stream = config_logger('cli.test')
2626
logger.info('hi')
2727
log_json = JSONDecoder().decode(stream.getvalue())
2828
_, error = JsonValidator(JOB_LOG_SCHEMA).validate(log_json)
@@ -36,7 +36,7 @@ def test_set_correlation_id():
3636
cf_logging.init(level=logging.DEBUG)
3737
cf_logging.FRAMEWORK.context.set_correlation_id(correlation_id)
3838

39-
logger, stream = config_root_logger('cli.test')
39+
logger, stream = config_logger('cli.test')
4040
logger.info('hi')
4141

4242
log_json = JSONDecoder().decode(stream.getvalue())
@@ -50,7 +50,7 @@ def test_set_correlation_id():
5050
def test_exception_stacktrace():
5151
""" Test exception stacktrace is logged """
5252
cf_logging.init(level=logging.DEBUG)
53-
logger, stream = config_root_logger('cli.test')
53+
logger, stream = config_logger('cli.test')
5454

5555
try:
5656
return 1 / 0

tests/util.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ def check_log_record(stream, schema, expected):
2525
return error
2626

2727

28-
def config_root_logger(logger_name):
29-
""" Function to configure a JSONLogger and print the output into a stream"""
30-
stream = io.StringIO()
31-
logging.getLogger().handlers[0].stream = stream
32-
logger = logging.getLogger(logger_name)
33-
return logger, stream
34-
35-
3628
def config_logger(logger_name):
3729
""" Function to configure a JSONLogger and print the output into a stream"""
3830
stream = io.StringIO()

0 commit comments

Comments
 (0)