diff options
-rw-r--r-- | mock/__init__.py | 7 | ||||
-rw-r--r-- | mock/mock.py (renamed from mock.py) | 9 | ||||
-rw-r--r-- | mock/tests/__init__.py (renamed from tests/__init__.py) | 0 | ||||
-rw-r--r-- | mock/tests/__main__.py (renamed from tests/__main__.py) | 0 | ||||
-rw-r--r-- | mock/tests/support.py (renamed from tests/support.py) | 0 | ||||
-rw-r--r-- | mock/tests/testcallable.py (renamed from tests/testcallable.py) | 2 | ||||
-rw-r--r-- | mock/tests/testhelpers.py (renamed from tests/testhelpers.py) | 7 | ||||
-rw-r--r-- | mock/tests/testmagicmethods.py (renamed from tests/testmagicmethods.py) | 5 | ||||
-rw-r--r-- | mock/tests/testmock.py (renamed from tests/testmock.py) | 5 | ||||
-rw-r--r-- | mock/tests/testpatch.py (renamed from tests/testpatch.py) | 11 | ||||
-rw-r--r-- | mock/tests/testsentinel.py (renamed from tests/testsentinel.py) | 0 | ||||
-rw-r--r-- | mock/tests/testwith.py (renamed from tests/testwith.py) | 2 | ||||
-rw-r--r-- | requirements.txt | 2 | ||||
-rw-r--r-- | setup.cfg | 44 | ||||
-rwxr-xr-x | setup.py | 75 |
15 files changed, 78 insertions, 91 deletions
diff --git a/mock/__init__.py b/mock/__init__.py new file mode 100644 index 0000000..82a3110 --- /dev/null +++ b/mock/__init__.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import +import mock.mock as _mock +from mock.mock import * +__all__ = _mock.__all__ +#import mock.mock as _mock +#for name in dir(_mock): +# globals()[name] = getattr(_mock, name) @@ -32,6 +32,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from __future__ import absolute_import + __all__ = ( 'Mock', 'MagicMock', @@ -42,6 +44,7 @@ __all__ = ( 'call', 'create_autospec', 'FILTER_DIR', + 'CallableMixin', 'NonCallableMock', 'NonCallableMagicMock', 'mock_open', @@ -65,6 +68,7 @@ from types import ModuleType import six from six import wraps +import mock inPy3k = sys.version_info[0] == 3 @@ -147,6 +151,7 @@ if inPy3k: self = '__self__' builtin = 'builtins' +# NOTE: This FILTER_DIR is not used. The binding in mock.FILTER_DIR is. FILTER_DIR = True # Workaround for Python issue #12370 @@ -782,7 +787,7 @@ class NonCallableMock(Base): def __dir__(self): """Filter the output of `dir(mock)` to only useful members.""" - if not FILTER_DIR and getattr(object, '__dir__', None): + if not mock.FILTER_DIR and getattr(object, '__dir__', None): # object.__dir__ is not in 2.7 return object.__dir__(self) @@ -790,7 +795,7 @@ class NonCallableMock(Base): from_type = dir(type(self)) from_dict = list(self.__dict__) - if FILTER_DIR: + if mock.FILTER_DIR: # object.__dir__ is not in 2.7 from_type = [e for e in from_type if not e.startswith('_')] from_dict = [e for e in from_dict if not e.startswith('_') or diff --git a/tests/__init__.py b/mock/tests/__init__.py index 54ddf2e..54ddf2e 100644 --- a/tests/__init__.py +++ b/mock/tests/__init__.py diff --git a/tests/__main__.py b/mock/tests/__main__.py index 45c633a..45c633a 100644 --- a/tests/__main__.py +++ b/mock/tests/__main__.py diff --git a/tests/support.py b/mock/tests/support.py index 0cbdb2c..0cbdb2c 100644 --- a/tests/support.py +++ b/mock/tests/support.py diff --git a/tests/testcallable.py b/mock/tests/testcallable.py index 740870d..10acdc3 100644 --- a/tests/testcallable.py +++ b/mock/tests/testcallable.py @@ -3,7 +3,7 @@ # http://www.voidspace.org.uk/python/mock/ import unittest2 as unittest -from tests.support import is_instance, X, SomeClass +from mock.tests.support import is_instance, X, SomeClass from mock import ( Mock, MagicMock, NonCallableMagicMock, diff --git a/tests/testhelpers.py b/mock/tests/testhelpers.py index 6902c60..99316e5 100644 --- a/tests/testhelpers.py +++ b/mock/tests/testhelpers.py @@ -3,12 +3,13 @@ # http://www.voidspace.org.uk/python/mock/ import unittest2 as unittest -from tests.support import inPy3k +from mock.tests.support import inPy3k from mock import ( - call, _Call, create_autospec, MagicMock, - Mock, ANY, _CallList, patch, PropertyMock + call, create_autospec, MagicMock, + Mock, ANY, patch, PropertyMock ) +from mock.mock import _Call, _CallList from datetime import datetime diff --git a/tests/testmagicmethods.py b/mock/tests/testmagicmethods.py index 0fa2602..5e39770 100644 --- a/tests/testmagicmethods.py +++ b/mock/tests/testmagicmethods.py @@ -6,7 +6,7 @@ from __future__ import division import unittest2 as unittest -from tests.support import inPy3k +from mock.tests.support import inPy3k try: unicode @@ -18,7 +18,8 @@ except NameError: import inspect import sys import textwrap -from mock import Mock, MagicMock, _magics +from mock import Mock, MagicMock +from mock.mock import _magics diff --git a/tests/testmock.py b/mock/tests/testmock.py index 38d1699..17e7999 100644 --- a/tests/testmock.py +++ b/mock/tests/testmock.py @@ -3,7 +3,7 @@ # http://www.voidspace.org.uk/python/mock/ import unittest2 as unittest -from tests.support import ( +from mock.tests.support import ( callable, inPy3k, is_instance, next ) @@ -15,9 +15,10 @@ import mock from mock import ( call, DEFAULT, patch, sentinel, MagicMock, Mock, NonCallableMock, - NonCallableMagicMock, _CallList, + NonCallableMagicMock, create_autospec ) +from mock.mock import _CallList try: diff --git a/tests/testpatch.py b/mock/tests/testpatch.py index a2d0138..ce84df2 100644 --- a/tests/testpatch.py +++ b/mock/tests/testpatch.py @@ -7,14 +7,15 @@ import sys import unittest2 as unittest -from tests import support -from tests.support import inPy3k, SomeClass, is_instance, callable +from mock.tests import support +from mock.tests.support import inPy3k, SomeClass, is_instance, callable from mock import ( NonCallableMock, CallableMixin, patch, sentinel, - MagicMock, Mock, NonCallableMagicMock, patch, _patch, - DEFAULT, call, _get_target + MagicMock, Mock, NonCallableMagicMock, patch, + DEFAULT, call ) +from mock.mock import _patch, _get_target builtin_string = '__builtin__' if inPy3k: @@ -1622,7 +1623,7 @@ class PatchTest(unittest.TestCase): def test_patch_nested_autospec_repr(self): - p = patch('tests.support', autospec=True) + p = patch('mock.tests.support', autospec=True) m = p.start() try: self.assertIn(" name='support.SomeClass.wibble()'", diff --git a/tests/testsentinel.py b/mock/tests/testsentinel.py index 69b2042..69b2042 100644 --- a/tests/testsentinel.py +++ b/mock/tests/testsentinel.py diff --git a/tests/testwith.py b/mock/tests/testwith.py index 7939c92..fde2a63 100644 --- a/tests/testwith.py +++ b/mock/tests/testwith.py @@ -6,7 +6,7 @@ from warnings import catch_warnings import unittest2 as unittest -from tests.support import is_instance +from mock.tests.support import is_instance from mock import MagicMock, Mock, patch, sentinel, mock_open, call diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fe98ba1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +funcsigs;python_version<"3.3" +six @@ -1,5 +1,39 @@ -[build_sphinx] -source-dir=docs -build-dir=html -[sdist] -force-manifest = 1 +[metadata] +name = mock +summary = Rolling backport of unittest.mock for all Pythons +home-page = https://github.com/testing-cabal/mock +description-file = README.txt +author = Testing Cabal +author-email = testing-in-python@lists.idyll.org +classifier = + Development Status :: 5 - Production/Stable + Environment :: Console + Intended Audience :: Developers + License :: OSI Approved :: BSD License + Operating System :: OS Independent + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.2 + Programming Language :: Python :: 3.3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: Implementation :: Jython + Programming Language :: Python :: Implementation :: PyPy + Topic :: Software Development :: Libraries + Topic :: Software Development :: Libraries :: Python Modules + Topic :: Software Development :: Testing +keyword = + testing, test, mock, mocking, unittest, patching, stubs, fakes, doubles + +[extras] +test = + unittest2>=1.1.0 + +[files] +packages = mock + +[bdist_wheel] +universal = 1 @@ -1,72 +1,7 @@ -#! /usr/bin/env python +#!/usr/bin/env python +import setuptools -# Copyright (C) 2007-2012 Michael Foord & the mock team -# E-mail: fuzzyman AT voidspace DOT org DOT uk -# http://www.voidspace.org.uk/python/mock/ -from __version__ import __version__ - -import os - -from setuptools import setup - -NAME = 'mock' -MODULES = ['mock'] -DESCRIPTION = 'A Python Mocking and Patching Library for Testing' - -URL = "http://www.voidspace.org.uk/python/mock/" - -readme = os.path.join(os.path.dirname(__file__), 'README.txt') -LONG_DESCRIPTION = open(readme).read() - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Programming Language :: Python :: Implementation :: Jython', - 'Operating System :: OS Independent', - 'Topic :: Software Development :: Libraries', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Software Development :: Testing', -] - -AUTHOR = 'Michael Foord' -AUTHOR_EMAIL = 'michael@voidspace.org.uk' -KEYWORDS = ("testing test mock mocking unittest patching " - "stubs fakes doubles").split(' ') - -params = dict( - name=NAME, - version=__version__, - py_modules=MODULES, - - # metadata for upload to PyPI - author=AUTHOR, - author_email=AUTHOR_EMAIL, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - keywords=KEYWORDS, - url=URL, - classifiers=CLASSIFIERS, - extras_require={ - ':python_version<"3.3"': ['funcsigs'], - 'test': ['unittest2'], - }, - install_requires=['six'], - tests_require=['unittest2'], - test_suite='unittest2.collector', -) - - -setup(**params) +setuptools.setup( + setup_requires=['pbr'], + pbr=True) |