Drop dependency of unittest2; use stdlib unittest instead
Now that Python 2.6 support has been dropped (commit
b67fe8a6f55ba321b602740fdf0bf0d15f074f4f), can simply use Python
unittest. No unique features of unittest2 were in use that aren't also
available in the stdlib unittest. One less dependency.
diff --git a/.travis.yml b/.travis.yml
index a13b528..b80f444 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,6 +21,6 @@
- pip list
- python --version
script:
- - unit2
+ - python -m unittest discover
- if [ -z "$SKIP_DOCS" ]; then python setup.py build_sphinx; fi
- rst2html.py --strict README.rst README.html
diff --git a/docs/conf.py b/docs/conf.py
index d32357d..6368a01 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -33,7 +33,6 @@
import sys
import mock
from mock import * # yeah, I know :-/
-import unittest2
import __main__
if os.getcwd() not in sys.path:
diff --git a/docs/index.txt b/docs/index.txt
index 6c8e37b..9f6e3c2 100644
--- a/docs/index.txt
+++ b/docs/index.txt
@@ -90,7 +90,7 @@
Bug Reports
+++++++++++
-Mock uses `unittest2 <http://pypi.python.org/pypi/unittest2>`_ for its own
+Mock uses `unittest <https://docs.python.org/3/library/unittest.html>`_ for its own
Issues with the backport process, such as compatibility with a particular
Python, should be reported to the `bug tracker
<https://github.com/testing-cabal/mock/issues>`_. Feature requests and issues
diff --git a/mock/tests/testcallable.py b/mock/tests/testcallable.py
index 10acdc3..c3cf2e5 100644
--- a/mock/tests/testcallable.py
+++ b/mock/tests/testcallable.py
@@ -2,7 +2,7 @@
# E-mail: fuzzyman AT voidspace DOT org DOT uk
# http://www.voidspace.org.uk/python/mock/
-import unittest2 as unittest
+import unittest
from mock.tests.support import is_instance, X, SomeClass
from mock import (
diff --git a/mock/tests/testhelpers.py b/mock/tests/testhelpers.py
index a87df1b..eb38b21 100644
--- a/mock/tests/testhelpers.py
+++ b/mock/tests/testhelpers.py
@@ -3,7 +3,7 @@
# http://www.voidspace.org.uk/python/mock/
import six
-import unittest2 as unittest
+import unittest
from mock import (
call, create_autospec, MagicMock,
diff --git a/mock/tests/testmagicmethods.py b/mock/tests/testmagicmethods.py
index f47a202..73e5a0f 100644
--- a/mock/tests/testmagicmethods.py
+++ b/mock/tests/testmagicmethods.py
@@ -14,9 +14,9 @@
import inspect
import sys
import textwrap
+import unittest
import six
-import unittest2 as unittest
from mock import Mock, MagicMock
from mock.mock import _magics
@@ -405,7 +405,7 @@
mock = MagicMock()
def set_setattr():
mock.__setattr__ = lambda self, name: None
- self.assertRaisesRegex(AttributeError,
+ self.assertRaisesRegexp(AttributeError,
"Attempting to set unsupported magic method '__setattr__'.",
set_setattr
)
diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py
index 66323e9..f7049c6 100644
--- a/mock/tests/testmock.py
+++ b/mock/tests/testmock.py
@@ -8,7 +8,7 @@
import tempfile
import six
-import unittest2 as unittest
+import unittest
import mock
from mock import (
@@ -205,7 +205,7 @@
mock = create_autospec(f)
mock.side_effect = ValueError('Bazinga!')
- self.assertRaisesRegex(ValueError, 'Bazinga!', mock)
+ self.assertRaisesRegexp(ValueError, 'Bazinga!', mock)
@unittest.skipUnless('java' in sys.platform,
'This test only applies to Jython')
@@ -501,7 +501,7 @@
# this should be allowed
mock.something
- self.assertRaisesRegex(
+ self.assertRaisesRegexp(
AttributeError,
"Mock object has no attribute 'something_else'",
getattr, mock, 'something_else'
@@ -520,12 +520,12 @@
mock.x
mock.y
mock.__something__
- self.assertRaisesRegex(
+ self.assertRaisesRegexp(
AttributeError,
"Mock object has no attribute 'z'",
getattr, mock, 'z'
)
- self.assertRaisesRegex(
+ self.assertRaisesRegexp(
AttributeError,
"Mock object has no attribute '__foobar__'",
getattr, mock, '__foobar__'
@@ -591,13 +591,13 @@
def test_assert_called_with_message(self):
mock = Mock()
- self.assertRaisesRegex(AssertionError, 'Not called',
+ self.assertRaisesRegexp(AssertionError, 'Not called',
mock.assert_called_with)
def test_assert_called_once_with_message(self):
mock = Mock(name='geoffrey')
- self.assertRaisesRegex(AssertionError,
+ self.assertRaisesRegexp(AssertionError,
r"Expected 'geoffrey' to be called once\.",
mock.assert_called_once_with)
diff --git a/mock/tests/testpatch.py b/mock/tests/testpatch.py
index f31ccef..16fa168 100644
--- a/mock/tests/testpatch.py
+++ b/mock/tests/testpatch.py
@@ -6,7 +6,7 @@
import sys
import six
-import unittest2 as unittest
+import unittest
from mock.tests import support
from mock.tests.support import SomeClass, is_instance
diff --git a/mock/tests/testsentinel.py b/mock/tests/testsentinel.py
index 69b2042..3253fa3 100644
--- a/mock/tests/testsentinel.py
+++ b/mock/tests/testsentinel.py
@@ -2,7 +2,7 @@
# E-mail: fuzzyman AT voidspace DOT org DOT uk
# http://www.voidspace.org.uk/python/mock/
-import unittest2 as unittest
+import unittest
from mock import sentinel, DEFAULT
diff --git a/mock/tests/testwith.py b/mock/tests/testwith.py
index aa7812b..ad340ab 100644
--- a/mock/tests/testwith.py
+++ b/mock/tests/testwith.py
@@ -4,7 +4,7 @@
from warnings import catch_warnings
-import unittest2 as unittest
+import unittest
from mock.tests.support import is_instance
from mock import MagicMock, Mock, patch, sentinel, mock_open, call
diff --git a/setup.cfg b/setup.cfg
index 25c280b..02a9b7a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -29,8 +29,6 @@
testing, test, mock, mocking, unittest, patching, stubs, fakes, doubles
[extras]
-test =
- unittest2>=1.1.0
docs =
sphinx
diff --git a/tox.ini b/tox.ini
index d7fef31..4ac890b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,21 +2,14 @@
envlist = py27,pypy,py33,jython
[testenv]
-deps=unittest2
-commands={envbindir}/unit2 discover []
+commands={envbindir}/python -m unittest discover []
[testenv:py27]
commands=
- {envbindir}/unit2 discover []
+ {envbindir}/python -m unittest discover []
{envbindir}/sphinx-build -E -b doctest docs html
deps =
- unittest2
sphinx
-[testenv:py33]
-commands=
- {envbindir}/python -m unittest discover []
-deps =
-
# note for jython. Execute in tests directory:
-# rm `find . -name '*$py.class'`
\ No newline at end of file
+# rm `find . -name '*$py.class'`
diff --git a/unittest.cfg b/unittest.cfg
deleted file mode 100644
index b2d6f67..0000000
--- a/unittest.cfg
+++ /dev/null
@@ -1,95 +0,0 @@
-
-[unittest]
-plugins =
- unittest2.plugins.debugger
- unittest2.plugins.checker
- unittest2.plugins.doctestloader
- unittest2.plugins.matchregexp
- unittest2.plugins.moduleloading
- unittest2.plugins.testcoverage
- unittest2.plugins.growl
- unittest2.plugins.filtertests
- unittest2.plugins.junitxml
- unittest2.plugins.timed
- unittest2.plugins.counttests
- unittest2.plugins.logchannels
-
-excluded-plugins =
-
-# 0, 1 or 2 (default is 1)
-# quiet, normal or verbose
-# can be overriden at command line
-verbosity = normal
-
-# true or false
-# even if false can be switched on at command line
-catch =
-buffer =
-failfast =
-
-
-[matchregexp]
-always-on = False
-full-path = True
-
-[debugger]
-always-on = False
-errors-only = True
-
-[coverage]
-always-on = False
-config =
-report-html = False
-# only used if report-html is false
-annotate = False
-# defaults to './htmlcov/'
-html-directory =
-# if unset will output to console
-text-file =
-branch = False
-timid = False
-cover-pylib = False
-exclude-lines =
- # Have to re-enable the standard pragma
- pragma: no cover
-
- # Don't complain about missing debug-only code:
- def __repr__
- if self\.debug
-
- # Don't complain if tests don't hit defensive assertion code:
- raise AssertionError
- raise NotImplementedError
-
- # Don't complain if non-runnable code isn't run:
- if 0:
- if __name__ == .__main__.
-
-ignore-errors = False
-modules =
-
-[growl]
-always-on = False
-
-[doctest]
-always-on = False
-
-[module-loading]
-always-on = False
-
-[checker]
-always-on = False
-pep8 = False
-pyflakes = True
-
-[junit-xml]
-always-on = False
-path = junit.xml
-
-[timed]
-always-on = True
-threshold = 0.01
-
-[count]
-always-on = True
-enhanced = False