Hello community, here is the log from the commit of package python-oslotest for openSUSE:Factory checked in at 2015-09-02 07:54:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-oslotest (Old) and /work/SRC/openSUSE:Factory/.python-oslotest.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-oslotest" Changes: -------- --- /work/SRC/openSUSE:Factory/python-oslotest/python-oslotest.changes 2015-06-17 16:16:17.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-oslotest.new/python-oslotest.changes 2015-09-02 07:54:07.000000000 +0200 @@ -1,0 +2,51 @@ +Fri Aug 7 07:59:53 UTC 2015 - dmuel...@suse.com + +- update to 1.10.0: + * Allow TRACE and integer logging levels for 'OS_DEBUG' + * Updated from global requirements + +------------------------------------------------------------------- +Tue Jul 14 16:02:44 UTC 2015 - dmuel...@suse.com + +- update to 1.9.0: + * Fix use of mock + * Add documentation for cross-project unit testing + * Updated from global requirements + * Fix build break with Fixtures 1.3 + * Updated from global requirements + +------------------------------------------------------------------- +Wed Jun 24 07:26:34 UTC 2015 - tbecht...@suse.com + +- update to 1.8.0: + * Updated from global requirements + * Allow ``OS_DEBUG`` environment variable to specify log level + * Updated from global requirements + * always rebuild cross-test venv + * Add CreateFileWithContent fixture + * Create ConfigureLogging fixture + * Create CaptureOutput fixture + * Create Timeout wrapper fixture + * Document the mock attribute for mockpatch + +------------------------------------------------------------------- +Mon Jun 22 15:06:14 UTC 2015 - tbecht...@suse.com + +- update to 1.7.0: + * Updated from global requirements + * Fix argument handling in oslo_run_cross_tests + * Add class to deal with clouds.yaml support + * Remove unneeded runtime pbr dep + * Updated from global requirements + * Advertise support for Python3.4 / Remove support for Python 3.3 + * Do not sync run_cross_tests.sh + * Remove unused discover dependency + * Uncap library requirements for liberty + * Cleanup README.rst and setup.cfg + * mockpatch: factorize code + * Update to latest hacking + * Updated from global requirements + * mockpatch: fix a potential race condition +- Adjust Requires according to requirements.txt + +------------------------------------------------------------------- Old: ---- oslotest-1.5.1.tar.gz New: ---- oslotest-1.10.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-oslotest.spec ++++++ --- /var/tmp/diff_new_pack.BwRB9w/_old 2015-09-02 07:54:08.000000000 +0200 +++ /var/tmp/diff_new_pack.BwRB9w/_new 2015-09-02 07:54:08.000000000 +0200 @@ -17,7 +17,7 @@ Name: python-oslotest -Version: 1.5.1 +Version: 1.10.0 Release: 0 Summary: OpenStack test framework License: Apache-2.0 @@ -35,14 +35,15 @@ BuildRequires: python-testrepository >= 0.0.18 BuildRequires: python-testscenarios >= 0.4 BuildRequires: python-testtools >= 0.9.34 -Requires: python-fixtures >= 0.3.14 -Requires: python-mock >= 1 -Requires: python-mox3 >= 0.7 +Requires: python-fixtures >= 1.3.1 +Requires: python-mock >= 1.0.1 +Requires: python-mox3 >= 0.7.0 +Requires: python-os-client-config >= 1.4.0 Requires: python-python-subunit >= 0.0.18 -Requires: python-six >= 1.9 +Requires: python-six >= 1.9.0 Requires: python-testrepository >= 0.0.18 Requires: python-testscenarios >= 0.4 -Requires: python-testtools >= 0.9.36 +Requires: python-testtools >= 1.4.0 BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?suse_version} && 0%{?suse_version} <= 1110 BuildRequires: python-discover ++++++ oslotest-1.5.1.tar.gz -> oslotest-1.10.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/AUTHORS new/oslotest-1.10.0/AUTHORS --- old/oslotest-1.5.1/AUTHORS 2015-03-09 15:36:13.000000000 +0100 +++ new/oslotest-1.10.0/AUTHORS 2015-08-03 19:21:15.000000000 +0200 @@ -3,9 +3,11 @@ Alexander Gorodnev <agorod...@mirantis.com> Angus Salkeld <asalk...@redhat.com> Ben Nemec <bne...@redhat.com> +Brant Knudson <bknud...@us.ibm.com> Chang Bo Guo <guoc...@cn.ibm.com> Christian Berendt <bere...@b1-systems.de> Chuck Short <chuck.sh...@canonical.com> +Davanum Srinivas <dava...@gmail.com> Davanum Srinivas <d...@linux.vnet.ibm.com> Dirk Mueller <d...@dmllr.de> Doug Hellmann <doug.hellm...@dreamhost.com> @@ -19,6 +21,7 @@ Jeremy Stanley <fu...@yuggoth.org> Joe Gordon <joe.gord...@gmail.com> Joe Heck <he...@mac.com> +Jon Grimm <jgr...@linux.vnet.ibm.com> Joshua Harlow <harlo...@yahoo-inc.com> Julien Danjou <jul...@danjou.info> Luis A. Garcia <l...@linux.vnet.ibm.com> @@ -31,5 +34,6 @@ Sergey Kraynev <skray...@mirantis.com> Soren Hansen <so...@linux2go.dk> Steve Martinelli <steve...@ca.ibm.com> +Victor Stinner <vstin...@redhat.com> Yuriy Taraday <yorik....@gmail.com> Zhongyue Luo <zhongyue....@intel.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/ChangeLog new/oslotest-1.10.0/ChangeLog --- old/oslotest-1.5.1/ChangeLog 2015-03-09 15:36:13.000000000 +0100 +++ new/oslotest-1.10.0/ChangeLog 2015-08-03 19:21:15.000000000 +0200 @@ -1,6 +1,59 @@ CHANGES ======= +1.10.0 +------ + +* Allow TRACE and integer logging levels for 'OS_DEBUG' +* Updated from global requirements +* Updated from global requirements +* Updated from global requirements + +1.9.0 +----- + +* Fix use of mock +* Updated from global requirements +* Add documentation for cross-project unit testing +* Updated from global requirements +* Fix build break with Fixtures 1.3 +* Updated from global requirements + +1.8.0 +----- + +* Updated from global requirements +* Allow ``OS_DEBUG`` environment variable to specify log level +* Updated from global requirements +* always rebuild cross-test venv +* Add CreateFileWithContent fixture +* Create ConfigureLogging fixture +* Create CaptureOutput fixture +* Create Timeout wrapper fixture +* Document the mock attribute for mockpatch + +1.7.0 +----- + +* Updated from global requirements +* Fix argument handling in oslo_run_cross_tests +* Add class to deal with clouds.yaml support +* Remove unneeded runtime pbr dep +* Updated from global requirements +* Advertise support for Python3.4 / Remove support for Python 3.3 +* Do not sync run_cross_tests.sh +* Remove unused discover dependency + +1.6.0 +----- + +* Uncap library requirements for liberty +* Cleanup README.rst and setup.cfg +* mockpatch: factorize code +* Update to latest hacking +* Updated from global requirements +* mockpatch: fix a potential race condition + 1.5.1 ----- @@ -19,6 +72,7 @@ * Move the script for running pre-releases into oslotest * Update docs for new script name * Publish cross-test runner as part of oslotest +* Remove six.moves call * Fix for mktemp failure on osx * Activate pep8 check that _ is imported * Workflow documentation is now in infra-manual diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/PKG-INFO new/oslotest-1.10.0/PKG-INFO --- old/oslotest-1.5.1/PKG-INFO 2015-03-09 15:36:14.000000000 +0100 +++ new/oslotest-1.10.0/PKG-INFO 2015-08-03 19:21:15.000000000 +0200 @@ -1,7 +1,7 @@ Metadata-Version: 1.1 Name: oslotest -Version: 1.5.1 -Summary: OpenStack test framework +Version: 1.10.0 +Summary: Oslo test framework Home-page: http://launchpad.net/oslo Author: OpenStack Author-email: openstack-...@lists.openstack.org @@ -10,7 +10,8 @@ oslotest ========== - OpenStack test framework and test fixtures. + The Oslo Test framework provides common fixtures, support for debugging, and + better support for mocking results. * Free software: Apache license * Documentation: http://docs.openstack.org/developer/oslotest @@ -29,4 +30,4 @@ Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/README.rst new/oslotest-1.10.0/README.rst --- old/oslotest-1.5.1/README.rst 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/README.rst 2015-08-03 19:20:54.000000000 +0200 @@ -2,7 +2,8 @@ oslotest ========== -OpenStack test framework and test fixtures. +The Oslo Test framework provides common fixtures, support for debugging, and +better support for mocking results. * Free software: Apache license * Documentation: http://docs.openstack.org/developer/oslotest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/doc/source/api.rst new/oslotest-1.10.0/doc/source/api.rst --- old/oslotest-1.5.1/doc/source/api.rst 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/doc/source/api.rst 2015-08-03 19:20:54.000000000 +0200 @@ -10,6 +10,20 @@ .. autoclass:: oslotest.base.BaseTestCase :members: +oslotest.createfile +=================== + +.. automodule:: oslotest.createfile + :members: + :special-members: + +oslotest.log +============ + +.. automodule:: oslotest.log + :members: + :special-members: + oslotest.mockpatch ================== @@ -22,3 +36,16 @@ .. automodule:: oslotest.moxstubout :members: + +oslotest.output +=================== + +.. automodule:: oslotest.output + :members: + +oslotest.timeout +================ + +.. automodule:: oslotest.timeout + :members: + :special-members: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/doc/source/cross-testing.rst new/oslotest-1.10.0/doc/source/cross-testing.rst --- old/oslotest-1.5.1/doc/source/cross-testing.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/doc/source/cross-testing.rst 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,102 @@ +============================ + Cross-project Unit Testing +============================ + +Libraries in OpenStack have an unusual ability to introduce breaking +changes. All of the projects are run together from source in one form +or another during the integration tests, but they are not combined +from source when unit tests are run. The server applications do not +generally import code from other projects, so their unit tests are +isolated. The libraries, however, are fundamentally intended to be +used during unit tests as well as integration tests. Testing the full +cross-product of libraries and consuming projects would consume all +available test servers, and so we cannot run all of the tests on all +patches to the libraries. As an alternative, we have a few scripts in +``oslotest`` for running the unit tests in serial. The result takes +far too long (usually overnight) to run in the OpenStack +infrastructure. Instead, they are usually run by hand on a dedicated +system. A cloud VM works well for this purpose, especially considering +how much of it is now automated. + +Check Out OpenStack Source +========================== + +The first step for all of the cross-project unit tests tools is to +ensure that you have a full copy of the OpenStack source checked +out. You can do this yourself through gerrit's ssh API, or you can use +the ``clone_openstack.sh`` command in the tools directory of the +``openstack/oslo-incubator`` repository. + +For example:: + + $ mkdir -p ~/repos/openstack + $ cd ~/repos/openstack + $ git clone git://git.openstack.org/openstack/oslo-incubator + $ cd ~/repos + $ ./openstack/oslo-incubator/tools/clone_openstack.sh + +The first time the script runs it will take quite some time, since it +has to download the entire history of every OpenStack project. + +Testing One Project +=================== + +``oslo_run_cross_tests`` runs one set of unit tests for one library +against all of the consuming projects. It should be run from the +directory with the library to be tested, and passed arguments telling +it about another project whose tests should be run. + +For example, to run the ``py27`` test suite from nova using the +currently checked out sources for ``oslo.config``, run:: + + $ cd ~/repos/openstack/oslo.config + $ tox -e venv -- oslo_run_cross_tests ~/repos/openstack/nova py27 + +Testing All Consumers +===================== + +``oslo_run_pre_release_tests`` builds on ``oslo_run_cross_tests`` to +find all of the consuming projects and run their tests +automatically. The pre-release script needs to know where the source +has been checked out, so the first step is to create its configuration +file. + +Edit ``~/.oslo.conf`` to contain:: + + [DEFAULT] + repo_root = /path/to/repos + +Replace ``/path/to/repos`` with the full, expanded, absolute path to +the location where the source code was checked out. For example, if +you followed the instructions above using ``clone_openstack.sh`` in +``~/repos`` and your user name is ``theuser`` the path would be +``/home/theuser/repos``. + +Returning to the earlier example, to test ``oslo.config`` with all of +the projects that use it, go to the ``oslo.config`` source directory +and run ``oslo_run_pre_release_tests``. + +:: + + $ cd ~/repos/openstack/oslo.config + $ tox -e venv -- oslo_run_pre_release_tests + +The output for each test set is logged to a separate file in the +current directory, to make them easy to examine. + +Use the ``--update`` or ``-u`` option to force a ``git pull`` for each +consuming projects before running its tests (useful for maintaining a +long-running system to host these tests). + +Use the ``--verbose`` or ``-v`` option to report more verbosely about +what is happening, including the number of projects being tested. + +Use ``--env`` or ``-e`` to add a tox environment to test. By default +the ``py27`` and ``pep8`` environments are used because those have +been shown to provide a good balance between finding problems and +running the tests quickly. + +Use the ``--ref`` option to test a specific commit reference of the +library under test. The default is to leave the source directory +untouched, but if this option is specified ``git checkout`` is used to +force the source tree to the specified reference. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/doc/source/index.rst new/oslotest-1.10.0/doc/source/index.rst --- old/oslotest-1.5.1/doc/source/index.rst 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/doc/source/index.rst 2015-08-03 19:20:54.000000000 +0200 @@ -13,6 +13,7 @@ api testing features + cross-testing resources contributing history diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/openstack-common.conf new/oslotest-1.10.0/openstack-common.conf --- old/oslotest-1.5.1/openstack-common.conf 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/openstack-common.conf 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -[DEFAULT] - -# The list of modules to copy from oslo-incubator.git -script = tools/run_cross_tests.sh - -# The base module to hold the copy of openstack.common -base=oslotest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/__init__.py new/oslotest-1.10.0/oslotest/__init__.py --- old/oslotest-1.5.1/oslotest/__init__.py 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/__init__.py 2015-08-03 19:20:54.000000000 +0200 @@ -14,4 +14,3 @@ six.add_move(six.MovedModule('mock', 'mock', 'unittest.mock')) -six.add_move(six.MovedModule('mox', 'mox3.mox', 'mox3.mox')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/base.py new/oslotest-1.10.0/oslotest/base.py --- old/oslotest-1.5.1/oslotest/base.py 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/base.py 2015-08-03 19:20:54.000000000 +0200 @@ -15,12 +15,12 @@ """Common utilities used in testing""" -import logging -import os -import tempfile - import fixtures -import six +from oslotest import createfile +from oslotest import log +from oslotest import output +from oslotest import timeout + from six.moves import mock import testtools @@ -45,7 +45,8 @@ it produces. If the environment variable ``OS_DEBUG`` is set to a true value, - debug logging is enabled. + debug logging is enabled. Alternatively, the ``OS_DEBUG`` + environment variable can be set to a valid log level. If the environment variable ``OS_LOG_CAPTURE`` is set to a true value, a logging fixture is installed to capture the log output. @@ -96,38 +97,13 @@ self.useFixture(fixtures.TempHomeDir()) def _set_timeout(self): - test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) - try: - test_timeout = int(test_timeout) - except ValueError: - # If timeout value is invalid do not set a timeout. - test_timeout = 0 - if test_timeout > 0: - self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) + self.useFixture(timeout.Timeout()) def _fake_output(self): - if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: - stdout = self.useFixture(fixtures.StringStream('stdout')).stream - self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) - if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: - stderr = self.useFixture(fixtures.StringStream('stderr')).stream - self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) + self.output_fixture = self.useFixture(output.CaptureOutput()) def _fake_logs(self): - level = None - if os.environ.get('OS_DEBUG') in _TRUE_VALUES: - level = logging.DEBUG - capture_logs = os.environ.get('OS_LOG_CAPTURE') in _TRUE_VALUES - if capture_logs: - self.logger = self.useFixture( - fixtures.FakeLogger( - format=_LOG_FORMAT, - level=level, - nuke_handlers=capture_logs, - ) - ) - else: - logging.basicConfig(format=_LOG_FORMAT, level=level) + self.log_fixture = self.useFixture(log.ConfigureLogging()) def create_tempfiles(self, files, ext='.conf', default_encoding='utf-8'): """Safely create temporary files. @@ -150,16 +126,11 @@ else: basename, contents = f encoding = default_encoding - if isinstance(contents, six.text_type): - contents = contents.encode(encoding) - if not os.path.isabs(basename): - (fd, path) = tempfile.mkstemp(prefix=basename, suffix=ext) - else: - path = basename + ext - fd = os.open(path, os.O_CREAT | os.O_WRONLY) - tempfiles.append(path) - try: - os.write(fd, contents) - finally: - os.close(fd) + fix = self.useFixture(createfile.CreateFileWithContent( + filename=basename, + contents=contents, + ext=ext, + encoding=encoding, + )) + tempfiles.append(fix.path) return tempfiles diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/createfile.py new/oslotest-1.10.0/oslotest/createfile.py --- old/oslotest-1.5.1/oslotest/createfile.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/createfile.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,70 @@ +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os +import tempfile + +import fixtures +import six + + +class CreateFileWithContent(fixtures.Fixture): + """Create a temporary file with the given content. + + Creates a file using a predictable name, to be used by tests for + code that need a filename to load data or otherwise interact with + the real filesystem. + + .. warning:: + + It is the responsibility of the caller to ensure that the file + is removed. + + Users of this fixture may also want to use + :class:`fixtures.NestedTempfile` to set the temporary directory + somewhere safe and to ensure the files are cleaned up. + + .. py:attribute:: path + + The canonical name of the file created. + + :param filename: Base file name or full literal path to the file + to be created. + :param contents: The data to write to the file. Unicode data will + be encoded before being written. + :param ext: An extension to add to filename. + :param encoding: An encoding to use for unicode data (ignored for + byte strings). + + """ + + def __init__(self, filename, contents, ext='.conf', encoding='utf-8'): + self._filename = filename + self._contents = contents + self._ext = ext + self._encoding = encoding + + def setUp(self): + super(CreateFileWithContent, self).setUp() + contents = self._contents + if isinstance(contents, six.text_type): + contents = contents.encode(self._encoding) + if not os.path.isabs(self._filename): + (fd, self.path) = tempfile.mkstemp(prefix=self._filename, + suffix=self._ext) + else: + self.path = self._filename + self._ext + fd = os.open(self.path, os.O_CREAT | os.O_WRONLY) + try: + os.write(fd, contents) + finally: + os.close(fd) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/functional.py new/oslotest-1.10.0/oslotest/functional.py --- old/oslotest-1.5.1/oslotest/functional.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/functional.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,59 @@ +# Copyright (c) 2015 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 +# +# 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. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os_client_config + + +def _get_openstack_auth(openstack_config, cloud_name, override_name): + try: + cloud_config = openstack_config.get_one_cloud(cloud_name) + except os_client_config.exceptions.OpenStackConfigException: + try: + cloud_config = openstack_config.get_one_cloud( + 'devstack', auth=dict( + username=override_name, project_name=override_name)) + except os_client_config.exceptions.OpenStackConfigException: + try: + cloud_config = openstack_config.get_one_cloud('envvars') + except os_client_config.exceptions.OpenStackConfigException: + cloud_config = None + return cloud_config + + +class FunctionalAuth(object): + + def __init__(self): + # Collecting of credentials: + # + # Grab the cloud config from a user's clouds.yaml file. + # First look for a functional_admin cloud, as this is a cloud + # that the user may have defined for functional testing that has + # admin credentials. + # + # If that is not found, get the devstack config and override the + # username and project_name to be admin so that admin credentials + # will be used. + # + # Finally, fall back to looking for environment variables to support + # existing users running these the old way. + openstack_config = os_client_config.config.OpenStackConfig() + self._cloud_config = {} + self._cloud_config['admin'] = _get_openstack_auth( + openstack_config, 'functional_admin', 'admin') + self._cloud_config['user'] = _get_openstack_auth( + openstack_config, 'functional_user', 'demo') + + def get_auth_info(self, name): + return self._cloud_config[name].config['auth'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/log.py new/oslotest-1.10.0/oslotest/log.py --- old/oslotest-1.5.1/oslotest/log.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/log.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,91 @@ +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +import os + +import fixtures + +_TRUE_VALUES = ('True', 'true', '1', 'yes') +_FALSE_VALUES = ('False', 'false', '0', 'no') +_BASE_LOG_LEVELS = ('DEBUG', 'INFO', 'WARN', 'WARNING', 'ERROR', 'CRITICAL') +_LOG_LEVELS = dict((n, getattr(logging, n)) for n in _BASE_LOG_LEVELS) +_LOG_LEVELS.update({ + 'TRACE': 5, +}) + + +def _try_int(value): + """Try to make some value into an int.""" + try: + return int(value) + except (ValueError, TypeError): + return None + + +class ConfigureLogging(fixtures.Fixture): + """Configure logging. + + The behavior is managed through two environment variables. If + ``OS_DEBUG`` is true then the logging level is set to debug. If + ``OS_LOG_CAPTURE`` is true a FakeLogger is configured. Alternatively, + ``OS_DEBUG`` can be set to an explicit log level, such as ``INFO``. + + "True" values include ``True``, ``true``, ``1`` and ``yes``. + Valid log levels include ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR``, + ``TRACE`` and ``CRITICAL`` (or any other valid integer logging level). + + .. py:attribute:: logger + + The logger fixture, if it is created. + + .. py:attribute:: level + + ``logging.DEBUG`` if debug logging is enabled, otherwise + the log level specified by ``OS_DEBUG``, otherwise ``None``. + + :param format: The logging format string to use. + + """ + + DEFAULT_FORMAT = "%(levelname)8s [%(name)s] %(message)s" + """Default log format""" + + def __init__(self, format=DEFAULT_FORMAT): + super(ConfigureLogging, self).__init__() + self._format = format + self.level = None + _os_debug = os.environ.get('OS_DEBUG') + _os_level = _try_int(_os_debug) + if _os_debug in _TRUE_VALUES: + self.level = logging.DEBUG + elif _os_level is not None: + self.level = _os_level + elif _os_debug in _LOG_LEVELS: + self.level = _LOG_LEVELS[_os_debug] + elif _os_debug and _os_debug not in _FALSE_VALUES: + raise ValueError('OS_DEBUG=%s is invalid.' % (_os_debug)) + self.capture_logs = os.environ.get('OS_LOG_CAPTURE') in _TRUE_VALUES + self.logger = None + + def setUp(self): + super(ConfigureLogging, self).setUp() + if self.capture_logs: + self.logger = self.useFixture( + fixtures.FakeLogger( + format=self._format, + level=self.level, + nuke_handlers=True, + ) + ) + else: + logging.basicConfig(format=self._format, level=self.level) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/mockpatch.py new/oslotest-1.10.0/oslotest/mockpatch.py --- old/oslotest-1.5.1/oslotest/mockpatch.py 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/mockpatch.py 2015-08-03 19:20:54.000000000 +0200 @@ -19,62 +19,63 @@ from six.moves import mock -class PatchObject(fixtures.Fixture): - """Deal with code around mock.""" +class _Base(fixtures.Fixture): + def setUp(self): + super(_Base, self).setUp() + _p = self._get_p() + self.addCleanup(_p.stop) + self.mock = _p.start() + + +class PatchObject(_Base): + """Deal with code around mock. + + .. py:attribute:: mock + + The mock. + + """ def __init__(self, obj, attr, new=mock.DEFAULT, **kwargs): - self.obj = obj - self.attr = attr - self.kwargs = kwargs - self.new = new + super(PatchObject, self).__init__() + self._get_p = lambda: mock.patch.object(obj, attr, new, **kwargs) - def setUp(self): - super(PatchObject, self).setUp() - _p = mock.patch.object(self.obj, self.attr, self.new, **self.kwargs) - self.mock = _p.start() - self.addCleanup(_p.stop) +class Patch(_Base): + """Deal with code around mock. + + .. py:attribute:: mock -class Patch(fixtures.Fixture): - """Deal with code around mock.patch.""" + The mock. + + """ def __init__(self, obj, new=mock.DEFAULT, **kwargs): - self.obj = obj - self.kwargs = kwargs - self.new = new + super(Patch, self).__init__() + self._get_p = lambda: mock.patch(obj, new, **kwargs) - def setUp(self): - super(Patch, self).setUp() - _p = mock.patch(self.obj, self.new, **self.kwargs) - self.mock = _p.start() - self.addCleanup(_p.stop) +class Multiple(_Base): + """Deal with code around mock.patch.multiple. -class Multiple(fixtures.Fixture): - """Deal with code around mock.patch.multiple.""" + Pass name=value to replace obj.name with value. - # Default value to trigger a MagicMock to be created for a named - # attribute. - DEFAULT = mock.DEFAULT + Pass name= :py:attr:`Multiple.DEFAULT` to replace obj.name with a MagicMock + instance. - def __init__(self, obj, **kwargs): - """Initialize the mocks + :param obj: Object or name containing values being mocked. + :type obj: str or object + :param kwargs: names and values of attributes of obj to be mocked. - Pass name=value to replace obj.name with value. + .. py:attribute:: mock - Pass name=Multiple.DEFAULT to replace obj.name with a - MagicMock instance. + The mock. - :param obj: Object or name containing values being mocked. - :type obj: str or object - :param kwargs: names and values of attributes of obj to be mocked. + """ - """ - self.obj = obj - self.kwargs = kwargs + DEFAULT = mock.DEFAULT + """Triggers a MagicMock to be created for a named attribute.""" - def setUp(self): - super(Multiple, self).setUp() - _p = mock.patch.multiple(self.obj, **self.kwargs) - self.mock = _p.start() - self.addCleanup(_p.stop) + def __init__(self, obj, **kwargs): + super(Multiple, self).__init__() + self._get_p = lambda: mock.patch.multiple(obj, **kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/moxstubout.py new/oslotest-1.10.0/oslotest/moxstubout.py --- old/oslotest-1.5.1/oslotest/moxstubout.py 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/moxstubout.py 2015-08-03 19:20:54.000000000 +0200 @@ -16,7 +16,7 @@ # under the License. import fixtures -from six.moves import mox +from mox3 import mox class MoxStubout(fixtures.Fixture): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/output.py new/oslotest-1.10.0/oslotest/output.py --- old/oslotest-1.5.1/oslotest/output.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/output.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,55 @@ +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +import fixtures + +_TRUE_VALUES = ('True', 'true', '1', 'yes') + + +class CaptureOutput(fixtures.Fixture): + """Optionally capture the output streams. + + The behavior is managed through two environment variables. If + ``OS_STDOUT_CAPTURE`` is true then stdout is captured and if + ``OS_STDERR_CAPTURE`` is true then stderr is captured. + + "True" values include ``True``, ``true``, ``1``, and ``yes``. + + .. py:attribute:: stdout + + The ``stream`` attribute from a :class:`StringStream` instance + replacing stdout. + + .. py:attribute:: stderr + + The ``stream`` attribute from a :class:`StringStream` instance + replacing stderr. + + """ + + def __init__(self): + super(CaptureOutput, self).__init__() + self.stdout = None + self.stderr = None + + def setUp(self): + super(CaptureOutput, self).setUp() + if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: + self._stdout_fixture = fixtures.StringStream('stdout') + self.stdout = self.useFixture(self._stdout_fixture).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.stdout)) + if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: + self._stderr_fixture = fixtures.StringStream('stderr') + self.stderr = self.useFixture(self._stderr_fixture).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', self.stderr)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest/timeout.py new/oslotest-1.10.0/oslotest/timeout.py --- old/oslotest-1.5.1/oslotest/timeout.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/oslotest/timeout.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,34 @@ +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import fixtures + +import os + + +class Timeout(fixtures.Fixture): + """Set the maximum length of time for the test to run. + + Uses OS_TEST_TIMEOUT to get the timeout. + + """ + + def setUp(self): + super(Timeout, self).setUp() + test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) + try: + test_timeout = int(test_timeout) + except ValueError: + # If timeout value is invalid do not set a timeout. + test_timeout = 0 + if test_timeout > 0: + self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest.egg-info/PKG-INFO new/oslotest-1.10.0/oslotest.egg-info/PKG-INFO --- old/oslotest-1.5.1/oslotest.egg-info/PKG-INFO 2015-03-09 15:36:13.000000000 +0100 +++ new/oslotest-1.10.0/oslotest.egg-info/PKG-INFO 2015-08-03 19:21:15.000000000 +0200 @@ -1,7 +1,7 @@ Metadata-Version: 1.1 Name: oslotest -Version: 1.5.1 -Summary: OpenStack test framework +Version: 1.10.0 +Summary: Oslo test framework Home-page: http://launchpad.net/oslo Author: OpenStack Author-email: openstack-...@lists.openstack.org @@ -10,7 +10,8 @@ oslotest ========== - OpenStack test framework and test fixtures. + The Oslo Test framework provides common fixtures, support for debugging, and + better support for mocking results. * Free software: Apache license * Documentation: http://docs.openstack.org/developer/oslotest @@ -29,4 +30,4 @@ Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest.egg-info/SOURCES.txt new/oslotest-1.10.0/oslotest.egg-info/SOURCES.txt --- old/oslotest-1.5.1/oslotest.egg-info/SOURCES.txt 2015-03-09 15:36:14.000000000 +0100 +++ new/oslotest-1.10.0/oslotest.egg-info/SOURCES.txt 2015-08-03 19:21:15.000000000 +0200 @@ -8,7 +8,6 @@ LICENSE MANIFEST.in README.rst -openstack-common.conf requirements.txt setup.cfg setup.py @@ -17,6 +16,7 @@ doc/source/api.rst doc/source/conf.py doc/source/contributing.rst +doc/source/cross-testing.rst doc/source/features.rst doc/source/history.rst doc/source/index.rst @@ -25,8 +25,13 @@ doc/source/testing.rst oslotest/__init__.py oslotest/base.py +oslotest/createfile.py +oslotest/functional.py +oslotest/log.py oslotest/mockpatch.py oslotest/moxstubout.py +oslotest/output.py +oslotest/timeout.py oslotest.egg-info/PKG-INFO oslotest.egg-info/SOURCES.txt oslotest.egg-info/dependency_links.txt @@ -39,8 +44,12 @@ tests/__init__.py tests/unit/__init__.py tests/unit/test_base.py +tests/unit/test_createfile.py +tests/unit/test_log.py tests/unit/test_mockpatch.py tests/unit/test_moxstubout.py +tests/unit/test_output.py +tests/unit/test_timeout.py tools/oslo_debug_helper tools/oslo_run_cross_tests tools/oslo_run_pre_release_tests \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest.egg-info/pbr.json new/oslotest-1.10.0/oslotest.egg-info/pbr.json --- old/oslotest-1.5.1/oslotest.egg-info/pbr.json 2015-03-09 15:36:13.000000000 +0100 +++ new/oslotest-1.10.0/oslotest.egg-info/pbr.json 2015-08-03 19:21:15.000000000 +0200 @@ -1 +1 @@ -{"is_release": true, "git_version": "5020f1a"} \ No newline at end of file +{"git_version": "358f5b3", "is_release": true} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/oslotest.egg-info/requires.txt new/oslotest-1.10.0/oslotest.egg-info/requires.txt --- old/oslotest-1.5.1/oslotest.egg-info/requires.txt 2015-03-09 15:36:13.000000000 +0100 +++ new/oslotest-1.10.0/oslotest.egg-info/requires.txt 2015-08-03 19:21:15.000000000 +0200 @@ -1,10 +1,9 @@ -pbr>=0.6,!=0.7,<1.0 -discover -fixtures>=0.3.14 +fixtures>=1.3.1 python-subunit>=0.0.18 six>=1.9.0 testrepository>=0.0.18 testscenarios>=0.4 -testtools>=0.9.36,!=1.2.0 -mock>=1.0 +testtools>=1.4.0 +mock>=1.2 mox3>=0.7.0 +os-client-config>=1.4.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/requirements.txt new/oslotest-1.10.0/requirements.txt --- old/oslotest-1.5.1/requirements.txt 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/requirements.txt 2015-08-03 19:20:54.000000000 +0200 @@ -2,13 +2,12 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr>=0.6,!=0.7,<1.0 -discover -fixtures>=0.3.14 +fixtures>=1.3.1 python-subunit>=0.0.18 six>=1.9.0 testrepository>=0.0.18 testscenarios>=0.4 -testtools>=0.9.36,!=1.2.0 -mock>=1.0 +testtools>=1.4.0 +mock>=1.2 mox3>=0.7.0 +os-client-config>=1.4.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/setup.cfg new/oslotest-1.10.0/setup.cfg --- old/oslotest-1.5.1/setup.cfg 2015-03-09 15:36:14.000000000 +0100 +++ new/oslotest-1.10.0/setup.cfg 2015-08-03 19:21:15.000000000 +0200 @@ -1,6 +1,6 @@ [metadata] name = oslotest -summary = OpenStack test framework +summary = Oslo test framework description-file = README.rst author = OpenStack @@ -17,7 +17,7 @@ Programming Language :: Python :: 2.7 Programming Language :: Python :: 2.6 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.3 + Programming Language :: Python :: 3.4 [files] packages = @@ -27,10 +27,6 @@ tools/oslo_run_cross_tests tools/oslo_run_pre_release_tests -[global] -setup-hooks = - pbr.hooks.setup_hook - [build_sphinx] source-dir = doc/source build-dir = doc/build @@ -47,6 +43,6 @@ [egg_info] tag_date = 0 -tag_svn_revision = 0 tag_build = +tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/setup.py new/oslotest-1.10.0/setup.py --- old/oslotest-1.5.1/setup.py 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/setup.py 2015-08-03 19:20:54.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,5 +25,5 @@ pass setuptools.setup( - setup_requires=['pbr'], + setup_requires=['pbr>=1.3'], pbr=True) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/test-requirements.txt new/oslotest-1.10.0/test-requirements.txt --- old/oslotest-1.5.1/test-requirements.txt 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/test-requirements.txt 2015-08-03 19:20:54.000000000 +0200 @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=0.9.2,<0.10 +hacking<0.11,>=0.10.0 # when we can require tox>= 1.4, this can go into tox.ini: # [testenv:cover] @@ -10,5 +10,5 @@ coverage>=3.6 # this is required for the docs build jobs -sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 -oslosphinx>=2.2.0 # Apache-2.0 +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +oslosphinx>=2.5.0 # Apache-2.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tests/unit/test_base.py new/oslotest-1.10.0/tests/unit/test_base.py --- old/oslotest-1.5.1/tests/unit/test_base.py 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/tests/unit/test_base.py 2015-08-03 19:20:54.000000000 +0200 @@ -33,7 +33,7 @@ pass @mock.patch('os.environ.get') - @mock.patch.object(FakeTestCase, 'useFixture') + @mock.patch('oslotest.timeout.Timeout.useFixture') @mock.patch('fixtures.Timeout') def test_timeout(self, fixture_timeout_mock, fixture_mock, env_get_mock): env_get_mock.return_value = 1 @@ -44,26 +44,26 @@ self.assertEqual(fixture_mock.call_count, 1) @mock.patch('os.environ.get') - @mock.patch.object(FakeTestCase, 'useFixture') - def test_fake_logs_default(self, fixture_mock, env_get_mock): + def test_fake_logs_default(self, env_get_mock): # without debug and log capture - env_get_mock.side_effect = lambda value: {'OS_DEBUG': 0, - 'OS_LOG_CAPTURE': 0}[value] + env_get_mock.side_effect = lambda value, default=None: { + 'OS_DEBUG': 0, 'OS_LOG_CAPTURE': 0}.get(value, default) tc = self.FakeTestCase("test_fake_test") - tc._fake_logs() + tc.setUp() env_get_mock.assert_any_call('OS_LOG_CAPTURE') - env_get_mock.assert_any_calls('OS_DEBUG') - self.assertEqual(fixture_mock.call_count, 0) + env_get_mock.assert_any_call('OS_DEBUG') + self.assertFalse(tc.log_fixture.capture_logs) + self.assertIsNone(tc.log_fixture.logger) @mock.patch('os.environ.get') @mock.patch('logging.basicConfig') def test_fake_logs_with_debug(self, basic_logger_mock, env_get_mock): - env_get_mock.side_effect = lambda value: {'OS_DEBUG': 'True', - 'OS_LOG_CAPTURE': 0}[value] + env_get_mock.side_effect = lambda value, default=None: { + 'OS_DEBUG': 'True', 'OS_LOG_CAPTURE': 0}.get(value, default) tc = self.FakeTestCase("test_fake_test") - tc._fake_logs() + tc.setUp() env_get_mock.assert_any_call('OS_LOG_CAPTURE') - env_get_mock.assert_any_calls('OS_DEBUG') + env_get_mock.assert_any_call('OS_DEBUG') basic_logger_mock.assert_called_once_with(format=base._LOG_FORMAT, level=logging.DEBUG) @@ -74,10 +74,10 @@ 'OS_LOG_CAPTURE': 'True' }[value] tc = self.FakeTestCase("test_fake_test") - tc._fake_logs() + tc.setUp() env_get_mock.assert_any_call('OS_LOG_CAPTURE') - env_get_mock.assert_any_calls('OS_DEBUG') - self.assertEqual(fixture_mock.call_count, 1) + env_get_mock.assert_any_call('OS_DEBUG') + self.assertEqual(fixture_mock.call_count, 5) def test_mock_patch_cleanup_on_teardown(self): # create an object and save its reference @@ -99,6 +99,22 @@ # check that mock patches are cleaned up self.assertEqual(obj.value, obj.backup) + @mock.patch('os.environ') + def test_capture_output_disabled(self, mock_env): + mock_env.get.return_value = '' + tc = self.FakeTestCase("test_fake_test") + tc.setUp() + self.assertIs(None, tc.output_fixture.stdout) + self.assertIs(None, tc.output_fixture.stderr) + + @mock.patch('os.environ') + def test_enabled(self, mock_env): + mock_env.get.return_value = 'True' + tc = self.FakeTestCase("test_fake_test") + tc.setUp() + self.assertIsNot(None, tc.output_fixture.stdout) + self.assertIsNot(None, tc.output_fixture.stderr) + class TestManualMock(base.BaseTestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tests/unit/test_createfile.py new/oslotest-1.10.0/tests/unit/test_createfile.py --- old/oslotest-1.5.1/tests/unit/test_createfile.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/tests/unit/test_createfile.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Deutsche Telekom AG +# +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +import six + +from oslotest import base +from oslotest import createfile + + +class CreateFileWithContentTest(base.BaseTestCase): + + def test_create_unicode_files(self): + f = createfile.CreateFileWithContent( + "no_approve", + u'ಠ_ಠ', + ) + f.setUp() + with open(f.path, 'rb') as f: + contents = f.read() + self.assertEqual(u'ಠ_ಠ', six.text_type(contents, encoding='utf-8')) + + def test_create_unicode_files_encoding(self): + f = createfile.CreateFileWithContent( + "embarrassed", u'⊙﹏⊙', encoding='utf-8', + ) + f.setUp() + with open(f.path, 'rb') as f: + contents = f.read() + self.assertEqual(u'⊙﹏⊙', six.text_type(contents, encoding='utf-8')) + + def test_create_bad_encoding(self): + f = createfile.CreateFileWithContent( + "hrm", u'ಠ~ಠ', encoding='ascii', + ) + self.assertRaises(UnicodeError, f.setUp) + + def test_prefix(self): + f = createfile.CreateFileWithContent('testing', '') + f.setUp() + basename = os.path.basename(f.path) + self.assertTrue(basename.startswith('testing')) + + def test_ext(self): + f = createfile.CreateFileWithContent('testing', '', ext='.ending') + f.setUp() + basename = os.path.basename(f.path) + self.assertTrue(basename.endswith('.ending')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tests/unit/test_log.py new/oslotest-1.10.0/tests/unit/test_log.py --- old/oslotest-1.5.1/tests/unit/test_log.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/tests/unit/test_log.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- + +# Copyright 2014 Deutsche Telekom AG +# +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging + +from six.moves import mock +import testtools + +from oslotest import log + + +class ConfigureLoggingTestCase(testtools.TestCase): + + @mock.patch('os.environ.get') + def test_fake_logs_default(self, env_get_mock): + # without debug and log capture + env_get_mock.side_effect = lambda value, default=None: { + 'OS_DEBUG': 0, 'OS_LOG_CAPTURE': 0}.get(value, default) + f = log.ConfigureLogging() + f.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + env_get_mock.assert_any_call('OS_DEBUG') + self.assertFalse(f.capture_logs) + self.assertIsNone(f.logger) + + @mock.patch('os.environ.get') + @mock.patch('logging.basicConfig') + def test_fake_logs_with_debug(self, basic_logger_mock, env_get_mock): + env_get_mock.side_effect = lambda value, default=None: { + 'OS_DEBUG': 'True', 'OS_LOG_CAPTURE': 0}.get(value, default) + f = log.ConfigureLogging() + f.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + env_get_mock.assert_any_call('OS_DEBUG') + basic_logger_mock.assert_called_once_with( + format=log.ConfigureLogging.DEFAULT_FORMAT, + level=logging.DEBUG) + + @mock.patch('os.environ.get') + @mock.patch('logging.basicConfig') + def test_fake_logs_with_warning(self, basic_logger_mock, env_get_mock): + env_get_mock.side_effect = lambda value, default=None: { + 'OS_DEBUG': 'WARNING', 'OS_LOG_CAPTURE': 0}.get(value, default) + f = log.ConfigureLogging() + f.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + env_get_mock.assert_any_call('OS_DEBUG') + basic_logger_mock.assert_called_once_with( + format=log.ConfigureLogging.DEFAULT_FORMAT, + level=logging.WARNING) + + @mock.patch('os.environ.get') + @mock.patch('logging.basicConfig') + def test_fake_logs_with_trace_int(self, basic_logger_mock, env_get_mock): + env_get_mock.side_effect = lambda value, default=None: { + 'OS_DEBUG': '5', 'OS_LOG_CAPTURE': 0}.get(value, default) + f = log.ConfigureLogging() + f.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + env_get_mock.assert_any_call('OS_DEBUG') + basic_logger_mock.assert_called_once_with( + format=log.ConfigureLogging.DEFAULT_FORMAT, + level=5) + + @mock.patch('os.environ.get') + @mock.patch('logging.basicConfig') + def test_fake_logs_with_debug_int(self, basic_logger_mock, env_get_mock): + env_get_mock.side_effect = lambda value, default=None: { + 'OS_DEBUG': '10', 'OS_LOG_CAPTURE': 0}.get(value, default) + f = log.ConfigureLogging() + f.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + env_get_mock.assert_any_call('OS_DEBUG') + basic_logger_mock.assert_called_once_with( + format=log.ConfigureLogging.DEFAULT_FORMAT, + level=logging.DEBUG) + + @mock.patch('os.environ.get') + def test_fake_logs_with_log_capture(self, env_get_mock): + env_get_mock.side_effect = lambda value: {'OS_DEBUG': 0, + 'OS_LOG_CAPTURE': 'True' + }[value] + f = log.ConfigureLogging() + f.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + env_get_mock.assert_any_call('OS_DEBUG') + self.assertIsNotNone(f.logger) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tests/unit/test_moxstubout.py new/oslotest-1.10.0/tests/unit/test_moxstubout.py --- old/oslotest-1.5.1/tests/unit/test_moxstubout.py 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/tests/unit/test_moxstubout.py 2015-08-03 19:20:54.000000000 +0200 @@ -30,3 +30,4 @@ f.cleanUp() after2 = TestMoxStubout._stubable self.assertEqual(before, after2) + f._clear_cleanups() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tests/unit/test_output.py new/oslotest-1.10.0/tests/unit/test_output.py --- old/oslotest-1.5.1/tests/unit/test_output.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/tests/unit/test_output.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import sys + +from oslotest import output + +import mock +import testtools + + +class CaptureOutputTest(testtools.TestCase): + + @mock.patch('os.environ') + def test_disabled(self, mock_env): + mock_env.get.return_value = '' + f = output.CaptureOutput() + f.setUp() + self.assertIs(None, f.stdout) + self.assertIs(None, f.stderr) + self.assertIsNot(sys.stdout, f.stdout) + self.assertIsNot(sys.stderr, f.stderr) + + @mock.patch('os.environ') + def test_enabled(self, mock_env): + mock_env.get.return_value = 'True' + f = output.CaptureOutput() + f.setUp() + self.assertIsNot(None, f.stdout) + self.assertIsNot(None, f.stderr) + self.assertIs(sys.stdout, f.stdout) + self.assertIs(sys.stderr, f.stderr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tests/unit/test_timeout.py new/oslotest-1.10.0/tests/unit/test_timeout.py --- old/oslotest-1.5.1/tests/unit/test_timeout.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-1.10.0/tests/unit/test_timeout.py 2015-08-03 19:20:54.000000000 +0200 @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +# 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 +# +# 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. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock +import testtools + +from oslotest import timeout + + +class TimeoutTestCase(testtools.TestCase): + + @mock.patch('os.environ.get') + @mock.patch.object(timeout.Timeout, 'useFixture') + @mock.patch('fixtures.Timeout') + def test_timeout(self, fixture_timeout_mock, fixture_mock, env_get_mock): + env_get_mock.return_value = 1 + tc = timeout.Timeout() + tc.setUp() + env_get_mock.assert_called_once_with('OS_TEST_TIMEOUT', 0) + fixture_timeout_mock.assert_called_once_with(1, gentle=True) + self.assertEqual(fixture_mock.call_count, 1) + + @mock.patch('os.environ.get') + @mock.patch.object(timeout.Timeout, 'useFixture') + @mock.patch('fixtures.Timeout') + def test_no_timeout(self, fixture_timeout_mock, fixture_mock, + env_get_mock): + # Returning 0 means we don't install the timeout + env_get_mock.return_value = 0 + tc = timeout.Timeout() + tc.setUp() + env_get_mock.assert_called_once_with('OS_TEST_TIMEOUT', 0) + self.assertEqual(fixture_timeout_mock.call_count, 0) + self.assertEqual(fixture_mock.call_count, 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tools/oslo_run_cross_tests new/oslotest-1.10.0/tools/oslo_run_cross_tests --- old/oslotest-1.5.1/tools/oslo_run_cross_tests 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/tools/oslo_run_cross_tests 2015-08-03 19:20:54.000000000 +0200 @@ -9,32 +9,40 @@ # Fail the build if any command fails set -e -project_dir="$1" -shift -venv="$1" -shift -posargs="$*" - -if [ -z "$project_dir" -o -z "$venv" ] -then +function usage { cat - <<EOF ERROR: Missing argument(s) Usage: - $0 PROJECT_DIR VIRTUAL_ENV [POSARGS] + oslo_run_cross_tests PROJECT_DIR VIRTUAL_ENV [POSARGS] Example, run the python 2.7 tests for python-neutronclient: - $0 /opt/stack/python-neutronclient py27 - $0 /opt/stack/nova py27 xenapi + oslo_run_cross_tests /opt/stack/python-neutronclient py27 + oslo_run_cross_tests /opt/stack/nova py27 xenapi EOF - exit 1 + exit $1 +} + +if [[ $# -lt 2 ]]; then + usage 1 +fi + +project_dir="$1" +shift +venv="$1" +shift +posargs="$*" + +if [ -z "$project_dir" -o -z "$venv" ] +then + usage 2 fi # Set up the virtualenv without running the tests -(cd $project_dir && tox --notest -e $venv) +(cd $project_dir && tox --notest -r -e $venv) tox_envbin=$project_dir/.tox/$venv/bin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-1.5.1/tox.ini new/oslotest-1.10.0/tox.ini --- old/oslotest-1.5.1/tox.ini 2015-03-09 15:35:54.000000000 +0100 +++ new/oslotest-1.10.0/tox.ini 2015-08-03 19:20:54.000000000 +0200 @@ -1,6 +1,6 @@ [tox] distribute = False -envlist = py33,py34,py26,py27,pep8 +envlist = py34,py26,py27,pep8 [testenv] install_command = pip install -U {opts} {packages} @@ -30,4 +30,3 @@ [hacking] import_exceptions = six.moves.mock - six.moves.mox