Upgrade pytest from <3.3 to >=3.3

Remove dependency on pytest-capturelog, which is included in pytest 3.3.
This commit is contained in:
Stein Magnus Jodal 2018-04-01 01:23:04 +02:00
parent 4581451973
commit 2471e5d269
3 changed files with 22 additions and 18 deletions

View File

@ -13,8 +13,7 @@ mock
responses responses
# Test runners # Test runners
pytest<3.3.0 pytest>=3.3.0
pytest-capturelog
pytest-cov pytest-cov
pytest-xdist pytest-xdist
tox tox

View File

@ -33,7 +33,7 @@ def test_download_on_server_side_error(session, caplog):
result = http.download(session, URI) result = http.download(session, URI)
assert result is None 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): 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 result is None
assert ( assert (
'Download of %r failed due to connection timeout after 1.000s' % URI 'Download of %r failed due to connection timeout after 1.000s' % URI
in caplog.text()) in caplog.text)
@responses.activate @responses.activate
@ -60,4 +60,4 @@ def test_download_times_out_if_download_is_slow(session, caplog):
assert result is None assert result is None
assert ( assert (
'Download of %r failed due to download taking more than 1.000s' % URI 'Download of %r failed due to download taking more than 1.000s' % URI
in caplog.text()) in caplog.text)

View File

@ -1,5 +1,7 @@
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
import logging
import mock import mock
import pytest import pytest
@ -92,6 +94,7 @@ class TestTranslateURI(object):
def test_text_playlist_with_mpeg_stream( def test_text_playlist_with_mpeg_stream(
self, scanner, provider, caplog): self, scanner, provider, caplog):
caplog.set_level(logging.DEBUG)
scanner.scan.side_effect = [ scanner.scan.side_effect = [
# Scanning playlist # Scanning playlist
mock.Mock(mime='text/foo', playable=False), mock.Mock(mime='text/foo', playable=False),
@ -112,11 +115,11 @@ class TestTranslateURI(object):
# Check logging to ensure debuggability # Check logging to ensure debuggability
assert 'Unwrapping stream from URI: %s' % PLAYLIST_URI 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 'Unwrapping stream from URI: %s' % STREAM_URI
assert ( assert (
'Unwrapped potential audio/mpeg stream: %s' % STREAM_URI 'Unwrapped potential audio/mpeg stream: %s' % STREAM_URI
in caplog.text()) in caplog.text)
# Check proper Requests session setup # Check proper Requests session setup
assert responses.calls[0].request.headers['User-Agent'].startswith( assert responses.calls[0].request.headers['User-Agent'].startswith(
@ -146,6 +149,7 @@ class TestTranslateURI(object):
def test_scan_fails_but_playlist_parsing_succeeds( def test_scan_fails_but_playlist_parsing_succeeds(
self, scanner, provider, caplog): self, scanner, provider, caplog):
caplog.set_level(logging.DEBUG)
scanner.scan.side_effect = [ scanner.scan.side_effect = [
# Scanning playlist # Scanning playlist
exceptions.ScannerError('some failure'), exceptions.ScannerError('some failure'),
@ -160,18 +164,18 @@ class TestTranslateURI(object):
assert 'Unwrapping stream from URI: %s' % PLAYLIST_URI assert 'Unwrapping stream from URI: %s' % PLAYLIST_URI
assert ( assert (
'GStreamer failed scanning URI (%s)' % PLAYLIST_URI 'GStreamer failed scanning URI (%s)' % PLAYLIST_URI in caplog.text)
in caplog.text()) assert 'Parsed playlist (%s)' % PLAYLIST_URI in caplog.text
assert 'Parsed playlist (%s)' % PLAYLIST_URI in caplog.text()
assert ( assert (
'Unwrapped potential audio/mpeg stream: %s' % STREAM_URI 'Unwrapped potential audio/mpeg stream: %s' % STREAM_URI
in caplog.text()) in caplog.text)
assert result == STREAM_URI assert result == STREAM_URI
@responses.activate @responses.activate
def test_scan_fails_and_playlist_parsing_fails( def test_scan_fails_and_playlist_parsing_fails(
self, scanner, provider, caplog): self, scanner, provider, caplog):
caplog.set_level(logging.DEBUG)
scanner.scan.side_effect = exceptions.ScannerError('some failure') scanner.scan.side_effect = exceptions.ScannerError('some failure')
responses.add( responses.add(
responses.GET, STREAM_URI, responses.GET, STREAM_URI,
@ -181,15 +185,15 @@ class TestTranslateURI(object):
assert 'Unwrapping stream from URI: %s' % STREAM_URI assert 'Unwrapping stream from URI: %s' % STREAM_URI
assert ( assert (
'GStreamer failed scanning URI (%s)' % STREAM_URI 'GStreamer failed scanning URI (%s)' % STREAM_URI in caplog.text)
in caplog.text())
assert ( assert (
'Failed parsing URI (%s) as playlist; found potential stream.' 'Failed parsing URI (%s) as playlist; found potential stream.'
% STREAM_URI in caplog.text()) % STREAM_URI in caplog.text)
assert result == STREAM_URI assert result == STREAM_URI
@responses.activate @responses.activate
def test_failed_download_returns_none(self, scanner, provider, caplog): def test_failed_download_returns_none(self, scanner, provider, caplog):
caplog.set_level(logging.DEBUG)
scanner.scan.side_effect = [ scanner.scan.side_effect = [
mock.Mock(mime='text/foo', playable=False) mock.Mock(mime='text/foo', playable=False)
] ]
@ -204,10 +208,11 @@ class TestTranslateURI(object):
assert ( assert (
'Unwrapping stream from URI (%s) failed: ' 'Unwrapping stream from URI (%s) failed: '
'error downloading URI' % PLAYLIST_URI) in caplog.text() 'error downloading URI' % PLAYLIST_URI) in caplog.text
@responses.activate @responses.activate
def test_playlist_references_itself(self, scanner, provider, caplog): def test_playlist_references_itself(self, scanner, provider, caplog):
caplog.set_level(logging.DEBUG)
scanner.scan.side_effect = [ scanner.scan.side_effect = [
mock.Mock(mime='text/foo', playable=False) mock.Mock(mime='text/foo', playable=False)
] ]
@ -218,11 +223,11 @@ class TestTranslateURI(object):
result = provider.translate_uri(PLAYLIST_URI) 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 ( assert (
'Parsed playlist (%s) and found new URI: %s' 'Parsed playlist (%s) and found new URI: %s'
% (PLAYLIST_URI, PLAYLIST_URI)) in caplog.text() % (PLAYLIST_URI, PLAYLIST_URI)) in caplog.text
assert ( assert (
'Unwrapping stream from URI (%s) failed: ' '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 assert result is None