Make dependency on python-mock optional.

This commit is contained in:
Valentin Lorentz 2014-07-12 10:01:59 +02:00
parent 6f19088724
commit 0a9d6469f0
3 changed files with 13 additions and 5 deletions

View File

@ -5,3 +5,4 @@ python-gnupg
feedparser
sqlalchemy
SocksiPy-branch
mock

View File

@ -281,10 +281,6 @@ setup(
'python-dateutil <2.0,>=1.3',
'feedparser',
],
tests_require=[
'mock',
]
)

View File

@ -27,10 +27,20 @@
# POSSIBILITY OF SUCH DAMAGE.
###
import sys
import unittest
from supybot import questions
from supybot.test import SupyTestCase
import mock
if sys.version_info >= (2, 7, 0):
skipif = unittest.skipIf
else:
skipif = lambda x, y: None
try:
import mock
except ImportError:
mock=None
# so complicated construction because I want to
# gain the string 'y' instead of the character 'y'
@ -39,6 +49,7 @@ import mock
# better solution is usage of '==' operator ;)
_yes_answer = ''.join(['', 'y'])
@skipif(mock is None, 'python-mock is not installed.')
class TestYn(SupyTestCase):
def test_default_yes_selected(self):
questions.expect = mock.Mock(return_value=_yes_answer)