File tree 2 files changed +11
-1
lines changed
src/dakara_player/media_player
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,11 @@ def is_available():
90
90
Returns:
91
91
bool: `True` if VLC is useable.
92
92
"""
93
- return vlc is not None and vlc .Instance () is not None
93
+ try :
94
+ return vlc is not None and vlc .Instance () is not None
95
+ except NameError :
96
+ logger .exception ("Failed to start VLC." )
97
+ return False
94
98
95
99
def init_player (self , config , tempdir ):
96
100
"""Initialize the objects of VLC.
Original file line number Diff line number Diff line change @@ -210,6 +210,12 @@ def test_set_vlc_callback(self):
210
210
vlc .EventType .MediaPlayerEndReached , callback
211
211
)
212
212
213
+ @skipIf (vlc is None , "VLC not installed" )
214
+ def test_vlc_unavailable (self ):
215
+ """Test that is_available returns False when vlc.Instance raises a NameError."""
216
+ with patch .object (vlc , "Instance" , side_effect = NameError ()):
217
+ self .assertFalse (MediaPlayerVlc .is_available ())
218
+
213
219
@patch ("dakara_player.media_player.vlc.libvlc_get_version" )
214
220
def test_get_version_long_4_digits (self , mocked_libvlc_get_version ):
215
221
"""Test to get the VLC version when it is long and contains 4 digits."""
You can’t perform that action at this time.
0 commit comments