mirror of
https://github.com/caronc/apprise.git
synced 2025-08-19 12:55:56 +02:00
Apprise @notify decorator/plugin support (#625)
This commit is contained in:
@@ -29,19 +29,9 @@ import sys
|
||||
import types
|
||||
import pytest
|
||||
import apprise
|
||||
from helpers import module_reload
|
||||
from apprise.plugins.NotifyGnome import GnomeUrgency
|
||||
|
||||
try:
|
||||
# Python v3.4+
|
||||
from importlib import reload
|
||||
except ImportError:
|
||||
try:
|
||||
# Python v3.0-v3.3
|
||||
from imp import reload
|
||||
except ImportError:
|
||||
# Python v2.7
|
||||
pass
|
||||
|
||||
# Disable logging for a cleaner testing output
|
||||
import logging
|
||||
logging.disable(logging.CRITICAL)
|
||||
@@ -65,7 +55,7 @@ def test_plugin_gnome_general():
|
||||
# for the purpose of testing and capture the handling of the
|
||||
# library when it is missing
|
||||
del sys.modules[gi_name]
|
||||
reload(sys.modules['apprise.plugins.NotifyGnome'])
|
||||
module_reload('NotifyGnome')
|
||||
|
||||
# We need to fake our gnome environment for testing purposes since
|
||||
# the gi library isn't available in Travis CI
|
||||
@@ -100,18 +90,7 @@ def test_plugin_gnome_general():
|
||||
notify_obj.show.return_value = True
|
||||
mock_notify.new.return_value = notify_obj
|
||||
mock_pixbuf.new_from_file.return_value = True
|
||||
|
||||
# The following libraries need to be reloaded to prevent
|
||||
# TypeError: super(type, obj): obj must be an instance or subtype of type
|
||||
# This is better explained in this StackOverflow post:
|
||||
# https://stackoverflow.com/questions/31363311/\
|
||||
# any-way-to-manually-fix-operation-of-\
|
||||
# super-after-ipython-reload-avoiding-ty
|
||||
#
|
||||
reload(sys.modules['apprise.plugins.NotifyGnome'])
|
||||
reload(sys.modules['apprise.plugins'])
|
||||
reload(sys.modules['apprise.Apprise'])
|
||||
reload(sys.modules['apprise'])
|
||||
module_reload('NotifyGnome')
|
||||
|
||||
# Create our instance
|
||||
obj = apprise.Apprise.instantiate('gnome://', suppress_exceptions=False)
|
||||
@@ -293,18 +272,7 @@ def test_plugin_gnome_general():
|
||||
|
||||
# Emulate require_version function:
|
||||
gi.require_version.side_effect = ValueError()
|
||||
|
||||
# The following libraries need to be reloaded to prevent
|
||||
# TypeError: super(type, obj): obj must be an instance or subtype of type
|
||||
# This is better explained in this StackOverflow post:
|
||||
# https://stackoverflow.com/questions/31363311/\
|
||||
# any-way-to-manually-fix-operation-of-\
|
||||
# super-after-ipython-reload-avoiding-ty
|
||||
#
|
||||
reload(sys.modules['apprise.plugins.NotifyGnome'])
|
||||
reload(sys.modules['apprise.plugins'])
|
||||
reload(sys.modules['apprise.Apprise'])
|
||||
reload(sys.modules['apprise'])
|
||||
module_reload('NotifyGnome')
|
||||
|
||||
# We can now no longer load our instance
|
||||
# The object internally is marked disabled
|
||||
|
Reference in New Issue
Block a user