Skip to content

Commit 1d66e28

Browse files
committed
Add back in use of 3rd-party mock module for Python 3.5
Apparently there were some issues in the unitest.mock module in Python 3.5 (but not 3.4 or 3.6)
1 parent a6b5733 commit 1d66e28

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

tests/test_cmd2.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66
Released under MIT license, see LICENSE file
77
"""
88
import argparse
9+
from code import InteractiveConsole
910
import os
1011
import sys
1112
import io
1213
import tempfile
1314

14-
from unittest import mock
1515
import pytest
1616
import six
17-
18-
from code import InteractiveConsole
19-
20-
# Used for sm.input: raw_input() for Python 2 or input() for Python 3
2117
import six.moves as sm
2218

19+
# Python 3.5 had some regressions in the unitest.mock module, so use 3rd party mock if available
20+
try:
21+
import mock
22+
except ImportError:
23+
from unittest import mock
24+
2325
import cmd2
2426
from conftest import run_cmd, normalize, BASE_HELP, BASE_HELP_VERBOSE, \
2527
HELP_HISTORY, SHORTCUTS_TXT, SHOW_TXT, SHOW_LONG, StdOut

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ commands = py.test -v -n2 --forked
2222

2323
[testenv:py35]
2424
deps =
25+
mock
2526
pyparsing
2627
pyperclip
2728
pytest
@@ -33,6 +34,7 @@ commands = py.test -v -n2 --forked
3334

3435
[testenv:py35-win]
3536
deps =
37+
mock
3638
pyparsing
3739
pyperclip
3840
pyreadline

0 commit comments

Comments
 (0)