Fix the tests on OS X to remove the plugin path and the module when re-running the tests

This commit is contained in:
Raoul Snyman 2015-04-27 11:33:29 +02:00
parent 217b731a95
commit f638418b7b

View File

@ -23,6 +23,7 @@
Package to test the openlp.core.ui.media.vlcplayer package.
"""
import os
import sys
from unittest import TestCase
from tests.functional import patch
@ -35,14 +36,17 @@ class TestVLCPlayer(TestCase):
Test the functions in the :mod:`vlcplayer` module.
"""
@patch.dict(os.environ)
@patch('openlp.core.ui.media.vlcplayer.is_macosx')
def fix_vlc_22_plugin_path_test(self, mocked_is_macosx):
"""
Test that on OS X we set the VLC plugin path to fix a bug in the VLC module
"""
# GIVEN: We're on OS X
# GIVEN: We're on OS X and we don't have the VLC plugin path set
mocked_is_macosx.return_value = True
if 'VLC_PLUGIN_PATH' in os.environ:
del os.environ['VLC_PLUGIN_PATH']
if 'openlp.core.ui.media.vendor.vlc' in sys.modules:
del sys.modules['openlp.core.ui.media.vendor.vlc']
# WHEN: An checking if the player is available
get_vlc()
@ -58,8 +62,12 @@ class TestVLCPlayer(TestCase):
"""
Test that on Linux or some other non-OS X we do not set the VLC plugin path
"""
# GIVEN: We're not on OS X
# GIVEN: We're not on OS X and we don't have the VLC plugin path set
mocked_is_macosx.return_value = False
if 'VLC_PLUGIN_PATH' in os.environ:
del os.environ['VLC_PLUGIN_PATH']
if 'openlp.core.ui.media.vendor.vlc' in sys.modules:
del sys.modules['openlp.core.ui.media.vendor.vlc']
# WHEN: An checking if the player is available
get_vlc()