mirror of
https://github.com/caronc/apprise.git
synced 2025-08-19 04:47:20 +02:00
Added support for recent CPython and PyPy versions; Droped Python v2.7 Support (#680)
This commit is contained in:
@@ -24,14 +24,7 @@
|
||||
# THE SOFTWARE.
|
||||
|
||||
import os
|
||||
import sys
|
||||
try:
|
||||
# Python 3.x
|
||||
from unittest import mock
|
||||
|
||||
except ImportError:
|
||||
# Python 2.7
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import requests
|
||||
from helpers import AppriseURLTester
|
||||
@@ -225,13 +218,6 @@ def test_plugin_mailgun_attachments(mock_post):
|
||||
body='body', title='title', notify_type=NotifyType.INFO,
|
||||
attach=attach) is False
|
||||
|
||||
# Get a appropriate "builtin" module name for pythons 2/3.
|
||||
if sys.version_info.major >= 3:
|
||||
builtin_open_function = 'builtins.open'
|
||||
|
||||
else:
|
||||
builtin_open_function = '__builtin__.open'
|
||||
|
||||
# Test Valid Attachment (load 3)
|
||||
path = (
|
||||
os.path.join(TEST_VAR_DIR, 'apprise-test.gif'),
|
||||
@@ -243,7 +229,7 @@ def test_plugin_mailgun_attachments(mock_post):
|
||||
# Return our good configuration
|
||||
mock_post.side_effect = None
|
||||
mock_post.return_value = okay_response
|
||||
with mock.patch(builtin_open_function, side_effect=OSError()):
|
||||
with mock.patch('builtins.open', side_effect=OSError()):
|
||||
# We can't send the message we can't open the attachment for reading
|
||||
assert obj.notify(
|
||||
body='body', title='title', notify_type=NotifyType.INFO,
|
||||
@@ -251,14 +237,14 @@ def test_plugin_mailgun_attachments(mock_post):
|
||||
|
||||
# Do it again, but fail on the third file
|
||||
with mock.patch(
|
||||
builtin_open_function,
|
||||
'builtins.open',
|
||||
side_effect=(mock.Mock(), mock.Mock(), OSError())):
|
||||
|
||||
assert obj.notify(
|
||||
body='body', title='title', notify_type=NotifyType.INFO,
|
||||
attach=attach) is False
|
||||
|
||||
with mock.patch(builtin_open_function) as mock_open:
|
||||
with mock.patch('builtins.open') as mock_open:
|
||||
mock_fp = mock.Mock()
|
||||
mock_fp.seek.side_effect = OSError()
|
||||
mock_open.return_value = mock_fp
|
||||
|
Reference in New Issue
Block a user