Updated to use OpenStack standards.

This commit is contained in:
Monty Taylor 2013-05-21 16:54:51 -04:00
parent de1221109c
commit 24bd40737a
14 changed files with 147 additions and 82 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@ pip-log.txt
# Unit test / coverage reports
.coverage
.tox
.testrepository
#Translations
*.mo

4
.testr.conf Normal file
View File

@ -0,0 +1,4 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ ./ $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -1,9 +0,0 @@
language: python
python:
- "2.6"
- "2.7"
- "3.2"
install: pip install pep8
script:
- pep8 --ignore E111 *.py || echo "Done"
- nosetests

View File

@ -1,2 +1,6 @@
include COPYING.txt
include README.txt
include AUTHORS
include ChangeLog
exclude .gitignore
exclude .gitreview
global-exclude *.pyc

52
README.rst Normal file
View File

@ -0,0 +1,52 @@
Mox3 - Mock object framework for Python 3
=========================================
Mox3 is an unofficial port of the Google mox framework
(http://code.google.com/p/pymox/) to Python 3. It was meant to be as compatible
with mox as possible, but small enhancements have been made. The library was
tested on Python version 3.2, 2.7 and 2.6.
Use at your own risk ;)
To install:
$ python setup.py install
Running Tests
-------------
The testing system is based on a combination of tox and testr. The canonical
approach to running tests is to simply run the command `tox`. This will
create virtual environments, populate them with depenedencies and run all of
the tests that OpenStack CI systems run. Behind the scenes, tox is running
`testr run --parallel`, but is set up such that you can supply any additional
testr arguments that are needed to tox. For example, you can run:
`tox -- --analyze-isolation` to cause tox to tell testr to add
--analyze-isolation to its argument list.
It is also possible to run the tests inside of a virtual environment
you have created, or it is possible that you have all of the dependencies
installed locally already. In this case, you can interact with the testr
command directly. Running `testr run` will run the entire test suite. `testr
run --parallel` will run it in parallel (this is the default incantation tox
uses.) More information about testr can be found at:
http://wiki.openstack.org/testr
Basic Usage
-----------
The basic usage of mox3 is the same as with mox, but the initial import should
be made from the mox3 module:
from mox3 import mox
To learn how to use mox3 you may check the documentation of the original mox
framework:
http://code.google.com/p/pymox/wiki/MoxDocumentation
Original Copyright
------------------
Mox is Copyright 2008 Google Inc, and licensed under the Apache
License, Version 2.0; see the file COPYING.txt for details. If you would
like to help us improve Mox, join the group.

View File

@ -1,33 +0,0 @@
Mox3 - Mock object framework for Python 3.
Mox3 is an unofficial port of the Google mox framework
(http://code.google.com/p/pymox/) to Python 3. It was meant to be as compatible
with mox as possible, but small enhancements have been made. The library was
tested on Python version 3.2, 2.7 and 2.6.
Use at your own risk ;)
To install:
$ python setup.py install
To run Mox3 internal tests you should download python-nose package and execute
(in mox3 directory):
$ nosetests
The basic usage of mox3 is the same as with mox, but the initial import should
be made from the mox3 module:
from mox3 import mox
To learn how to use mox3 you may check the documentation of the original mox
framework:
http://code.google.com/p/pymox/wiki/MoxDocumentation
--
Mox is Copyright 2008 Google Inc, and licensed under the Apache
License, Version 2.0; see the file COPYING for details. If you would
like to help us improve Mox, join the group.

View File

@ -16,15 +16,15 @@
# This is a fork of the pymox library intended to work with Python 3.
# The file was modified by quermit@gmail.com and dawid.fatyga@gmail.com
"""A very basic test class derived from mox.MoxTestBase, used by mox_test.py.
"""A very basic test class derived from mox.MoxTestBase, used by test_mox.py.
The class defined in this module is used to test the features of
MoxTestBase and is not intended to be a standalone test. It needs to
be in a separate module, because otherwise the tests in this class
(which should not all pass) would be executed as part of the
mox_test.py test suite.
test_mox.py test suite.
See mox_test.MoxTestBaseTest for how this class is actually used.
See test_mox.MoxTestBaseTest for how this class is actually used.
"""
import os

View File

@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# This is a fork of the pymox library intended to work with Python 3.
# The file was modified by quermit@gmail.com and dawid.fatyga@gmail.com
@ -97,13 +96,13 @@ class AndTest(unittest.TestCase):
"""
test_dict = {"mock": "obj", "testing": "isCOOL"}
self.assertTrue(mox.And(mox.In("testing"),
mox.ContainsKeyValue("mock", "obj")) == test_dict)
mox.ContainsKeyValue("mock", "obj")) == test_dict)
def testAdvancedUsageFails(self):
"""Note: this test is reliant on In and ContainsKeyValue."""
test_dict = {"mock": "obj", "testing": "isCOOL"}
self.assertFalse(mox.And(mox.In("NOTFOUND"),
mox.ContainsKeyValue("mock", "obj")) == test_dict)
mox.ContainsKeyValue("mock", "obj")) == test_dict)
class FuncTest(unittest.TestCase):
@ -2275,8 +2274,8 @@ class MoxTestBaseMultipleInheritanceTest(mox.MoxTestBase, MyTestCase):
class MoxTestDontMockProperties(MoxTestBaseTest):
def testPropertiesArentMocked(self):
mock_class = self.mox.CreateMock(ClassWithProperties)
self.assertRaises(mox.UnknownMethodCallError, lambda:
mock_class.prop_attr)
self.assertRaises(mox.UnknownMethodCallError,
lambda: mock_class.prop_attr)
class TestClass(object):

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# This is a fork of the pymox library intended to work with Python 3.
# The file was modified by quermit@gmail.com and dawid.fatyga@gmail.com

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
d2to1>=0.2.10,<0.3
pbr>=0.5.10,<0.6

27
setup.cfg Normal file
View File

@ -0,0 +1,27 @@
[metadata]
name = mox3
summary = Mock object framework for Python
description-file =
README.rst
author = OpenStack
author-email = openstack-dev@lists.openstack.org
home-page = http://www.openstack.org/
classifiers =
Environment :: OpenStack
Programming Language :: Python
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Operating System :: OS Independent
Development Status :: 4 - Beta
Intended Audience :: Developers
Topic :: Software Development :: Testing
[files]
packages =
mox3
[global]
setup-hooks =
pbr.hooks.setup_hook

View File

@ -1,41 +1,21 @@
# Copyright 2008 Google Inc.
#!/usr/bin/env python
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# This is a fork of the pymox library intended to work with Python 3.
# The file was modified by quermit@gmail.com and dawid.fatyga@gmail.com
from distutils.core import setup
import setuptools
setup(name='mox3',
version='0.6.0',
packages=['mox3', 'mox3.tests'],
url='https://github.com/openstack-dev/mox3',
maintainer='OpenStack Developers',
maintainer_email='openstack-dev@lists.openstack.org',
license='Apache License, Version 2.0',
description='Mock object framework for Python 3',
long_description=('Mox3 is an unofficial port of the of the mox '
'framework to Python 3. The library was tested on '
'Python version 3.2, 2.7 and 2.6.'),
classifiers=['Programming Language :: Python',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Topic :: Software Development :: Testing'],
)
setuptools.setup(
setup_requires=['d2to1>=0.2.10,<0.3', 'pbr>=0.5.10,<0.6'],
d2to1=True)

12
test-requirements.txt Normal file
View File

@ -0,0 +1,12 @@
# this file lists dependencies required for the testing of heat
distribute>=0.6.28
# Install bounded pep8/pyflakes first, then let flake8 install
pep8==1.4.5
pyflakes==0.7.2
flake8==2.0
hacking>=0.5.3,<0.6
coverage
discover
testrepository>=0.0.13

27
tox.ini Normal file
View File

@ -0,0 +1,27 @@
[tox]
envlist = py26,py27,pep8
[testenv]
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
python tools/patch_tox_venv.py
python setup.py testr --slowest --testr-args='{posargs}'
[testenv:pep8]
commands = flake8
[testenv:venv]
commands = {posargs}
[testenv:cover]
setenv = VIRTUAL_ENV={envdir}
commands =
python setup.py testr --coverage
[flake8]
show-source = true
ignore = H,E11
builtins = _
exclude=.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg