diff --git a/dev-requirements.txt b/dev-requirements.txt index 512421e7..282ab1b2 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -13,8 +13,7 @@ mock responses # Test runners -pytest<3.3.0 -pytest-capturelog +pytest>=3.3.0 pytest-cov pytest-xdist tox diff --git a/tests/internal/test_http.py b/tests/internal/test_http.py index 6730777f..57078ce3 100644 --- a/tests/internal/test_http.py +++ b/tests/internal/test_http.py @@ -33,7 +33,7 @@ def test_download_on_server_side_error(session, caplog): result = http.download(session, URI) assert result is None - assert 'Problem downloading' in caplog.text() + assert 'Problem downloading' in caplog.text def test_download_times_out_if_connection_times_out(session_mock, caplog): @@ -45,7 +45,7 @@ def test_download_times_out_if_connection_times_out(session_mock, caplog): assert result is None assert ( 'Download of %r failed due to connection timeout after 1.000s' % URI - in caplog.text()) + in caplog.text) @responses.activate @@ -60,4 +60,4 @@ def test_download_times_out_if_download_is_slow(session, caplog): assert result is None assert ( 'Download of %r failed due to download taking more than 1.000s' % URI - in caplog.text()) + in caplog.text) diff --git a/tests/stream/test_playback.py b/tests/stream/test_playback.py index 1816f73e..dd3d161f 100644 --- a/tests/stream/test_playback.py +++ b/tests/stream/test_playback.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, unicode_literals +import logging + import mock import pytest @@ -92,6 +94,7 @@ class TestTranslateURI(object): def test_text_playlist_with_mpeg_stream( self, scanner, provider, caplog): + caplog.set_level(logging.DEBUG) scanner.scan.side_effect = [ # Scanning playlist mock.Mock(mime='text/foo', playable=False), @@ -112,11 +115,11 @@ class TestTranslateURI(object): # Check logging to ensure debuggability assert 'Unwrapping stream from URI: %s' % PLAYLIST_URI - assert 'Parsed playlist (%s)' % PLAYLIST_URI in caplog.text() + assert 'Parsed playlist (%s)' % PLAYLIST_URI in caplog.text assert 'Unwrapping stream from URI: %s' % STREAM_URI assert ( 'Unwrapped potential audio/mpeg stream: %s' % STREAM_URI - in caplog.text()) + in caplog.text) # Check proper Requests session setup assert responses.calls[0].request.headers['User-Agent'].startswith( @@ -146,6 +149,7 @@ class TestTranslateURI(object): def test_scan_fails_but_playlist_parsing_succeeds( self, scanner, provider, caplog): + caplog.set_level(logging.DEBUG) scanner.scan.side_effect = [ # Scanning playlist exceptions.ScannerError('some failure'), @@ -160,18 +164,18 @@ class TestTranslateURI(object): assert 'Unwrapping stream from URI: %s' % PLAYLIST_URI assert ( - 'GStreamer failed scanning URI (%s)' % PLAYLIST_URI - in caplog.text()) - assert 'Parsed playlist (%s)' % PLAYLIST_URI in caplog.text() + 'GStreamer failed scanning URI (%s)' % PLAYLIST_URI in caplog.text) + assert 'Parsed playlist (%s)' % PLAYLIST_URI in caplog.text assert ( 'Unwrapped potential audio/mpeg stream: %s' % STREAM_URI - in caplog.text()) + in caplog.text) assert result == STREAM_URI @responses.activate def test_scan_fails_and_playlist_parsing_fails( self, scanner, provider, caplog): + caplog.set_level(logging.DEBUG) scanner.scan.side_effect = exceptions.ScannerError('some failure') responses.add( responses.GET, STREAM_URI, @@ -181,15 +185,15 @@ class TestTranslateURI(object): assert 'Unwrapping stream from URI: %s' % STREAM_URI assert ( - 'GStreamer failed scanning URI (%s)' % STREAM_URI - in caplog.text()) + 'GStreamer failed scanning URI (%s)' % STREAM_URI in caplog.text) assert ( 'Failed parsing URI (%s) as playlist; found potential stream.' - % STREAM_URI in caplog.text()) + % STREAM_URI in caplog.text) assert result == STREAM_URI @responses.activate def test_failed_download_returns_none(self, scanner, provider, caplog): + caplog.set_level(logging.DEBUG) scanner.scan.side_effect = [ mock.Mock(mime='text/foo', playable=False) ] @@ -204,10 +208,11 @@ class TestTranslateURI(object): assert ( 'Unwrapping stream from URI (%s) failed: ' - 'error downloading URI' % PLAYLIST_URI) in caplog.text() + 'error downloading URI' % PLAYLIST_URI) in caplog.text @responses.activate def test_playlist_references_itself(self, scanner, provider, caplog): + caplog.set_level(logging.DEBUG) scanner.scan.side_effect = [ mock.Mock(mime='text/foo', playable=False) ] @@ -218,11 +223,11 @@ class TestTranslateURI(object): result = provider.translate_uri(PLAYLIST_URI) - assert 'Unwrapping stream from URI: %s' % PLAYLIST_URI in caplog.text() + assert 'Unwrapping stream from URI: %s' % PLAYLIST_URI in caplog.text assert ( 'Parsed playlist (%s) and found new URI: %s' - % (PLAYLIST_URI, PLAYLIST_URI)) in caplog.text() + % (PLAYLIST_URI, PLAYLIST_URI)) in caplog.text assert ( 'Unwrapping stream from URI (%s) failed: ' - 'playlist referenced itself' % PLAYLIST_URI) in caplog.text() + 'playlist referenced itself' % PLAYLIST_URI) in caplog.text assert result is None