Hello community, here is the log from the commit of package python-oslotest for openSUSE:Factory checked in at 2016-09-01 14:02:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2016-05-04 08:20:00.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-oslotest.new/python-oslotest.changes 2016-09-01 14:02:48.000000000 +0200 @@ -1,0 +2,30 @@ +Wed Aug 10 12:08:55 UTC 2016 - [email protected] + +- update to 2.8.0: + * Import mock so that it works on Python 3.x + * Fix parameters of assertEqual are misplaced + * Updated from global requirements + * Add Python 3.5 classifier and venv + +------------------------------------------------------------------- +Mon Jul 4 15:54:15 UTC 2016 - [email protected] + +- update to 2.6.0: + * Updated from global requirements + * Remove mockpatch re-implementations + +------------------------------------------------------------------- +Sun Jun 19 20:24:00 UTC 2016 - [email protected] + +- update to 2.4.0: + * Updated from global requirements + * Update .gitreview for stable/mitaka + * Add some gitignore files + * move unit tests into the oslotest package + * Updated from global requirements + * Hack to get back stopall cleanup behavior feature + * Fix misspelling + * Updated from global requirements + * Trival: Remove 'MANIFEST.in' + +------------------------------------------------------------------- Old: ---- oslotest-2.0.0.tar.gz New: ---- oslotest-2.8.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-oslotest.spec ++++++ --- /var/tmp/diff_new_pack.Cscy1j/_old 2016-09-01 14:02:49.000000000 +0200 +++ /var/tmp/diff_new_pack.Cscy1j/_new 2016-09-01 14:02:49.000000000 +0200 @@ -17,30 +17,29 @@ Name: python-oslotest -Version: 2.0.0 +Version: 2.8.0 Release: 0 Summary: OpenStack test framework License: Apache-2.0 Group: Development/Languages/Python Url: https://launchpad.net/oslotest -Source: https://pypi.python.org/packages/source/o/oslotest/oslotest-%{version}.tar.gz +Source0: https://pypi.io/packages/source/o/oslotest/oslotest-%{version}.tar.gz BuildRequires: openstack-macros +BuildRequires: python-debtcollector >= 1.2.0 BuildRequires: python-devel -BuildRequires: python-pbr -# Test requirements: -BuildRequires: python-debtcollector >= 0.3.0 -BuildRequires: python-fixtures >= 0.3.14 -BuildRequires: python-mock >= 1.0 +BuildRequires: python-fixtures >= 1.3.1 +BuildRequires: python-mock >= 1.2 BuildRequires: python-mox3 >= 0.7.0 +BuildRequires: python-pbr >= 1.6 BuildRequires: python-python-subunit >= 0.0.18 -BuildRequires: python-six +BuildRequires: python-six >= 1.9.0 BuildRequires: python-testrepository >= 0.0.18 BuildRequires: python-testscenarios >= 0.4 BuildRequires: python-testtools >= 1.4.0 Requires: python-fixtures >= 1.3.1 -Requires: python-mock >= 1.0.1 +Requires: python-mock >= 1.2 Requires: python-mox3 >= 0.7.0 -Requires: python-os-client-config >= 1.4.0 +Requires: python-os-client-config >= 1.13.1 Requires: python-python-subunit >= 0.0.18 Requires: python-six >= 1.9.0 Requires: python-testrepository >= 0.0.18 @@ -56,13 +55,13 @@ %setup -q -n oslotest-%{version} %build -%{__python2} setup.py build +%{py2_build} %install -%{__python2} setup.py install --prefix=%{_prefix} --root=%{buildroot} +%{py2_install} %check -testr init && testr run +%{__python2} setup.py test %files %license LICENSE ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Cscy1j/_old 2016-09-01 14:02:49.000000000 +0200 +++ /var/tmp/diff_new_pack.Cscy1j/_new 2016-09-01 14:02:49.000000000 +0200 @@ -1,4 +1,13 @@ <services> + <service mode="disabled" name="renderspec"> + <param name="input-template">https://raw.githubusercontent.com/openstack/rpm-packaging/master/openstack/oslotest/oslotest.spec.j2</param> + <param name="output-name">python-oslotest.spec</param> + <param name="requirements">https://raw.githubusercontent.com/openstack/rpm-packaging/master/global-requirements.txt</param> + </service> + <service mode="disabled" name="download_files"> + <param name="changesgenerate">enable</param> + </service> + <service mode="disabled" name="download_files"> <param name="changesgenerate">enable</param> </service> @@ -8,7 +17,4 @@ <service name="refresh_patches" mode="disabled"> <param name="changesgenerate">enable</param> </service> - <service name="python_requires" mode="disabled"> - </service> </services> - \ No newline at end of file ++++++ oslotest-2.0.0.tar.gz -> oslotest-2.8.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/AUTHORS new/oslotest-2.8.0/AUTHORS --- old/oslotest-2.0.0/AUTHORS 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/AUTHORS 2016-08-02 20:21:09.000000000 +0200 @@ -8,6 +8,7 @@ ChangBo Guo(gcb) <[email protected]> Christian Berendt <[email protected]> Chuck Short <[email protected]> +Danek Duvall <[email protected]> Davanum Srinivas <[email protected]> Davanum Srinivas <[email protected]> Dirk Mueller <[email protected]> @@ -28,6 +29,7 @@ Luis A. Garcia <[email protected]> Marc Koderer <[email protected]> Mark McLoughlin <[email protected]> +Masayuki Igawa <[email protected]> Mauro S. M. Rodrigues <[email protected]> Monty Taylor <[email protected]> Noorul Islam K M <[email protected]> @@ -40,3 +42,4 @@ Yuriy Taraday <[email protected]> Zhongyue Luo <[email protected]> venkatamahesh <[email protected]> +yan.haifeng <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/ChangeLog new/oslotest-2.8.0/ChangeLog --- old/oslotest-2.0.0/ChangeLog 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/ChangeLog 2016-08-02 20:21:08.000000000 +0200 @@ -1,6 +1,53 @@ CHANGES ======= +2.8.0 +----- + +* Import mock so that it works on Python 3.x +* Fix parameters of assertEqual are misplaced +* Updated from global requirements +* Add Python 3.5 classifier and venv + +2.7.0 +----- + +* Updated from global requirements + +2.6.0 +----- + +* Updated from global requirements + +2.5.0 +----- + +* Remove mockpatch re-implementations +* Updated from global requirements +* Updated from global requirements +* Updated from global requirements + +2.3.0 +----- + +* Add some gitignore files + +2.2.0 +----- + +* move unit tests into the oslotest package +* Updated from global requirements +* Hack to get back stopall cleanup behavior feature +* Fix misspelling + +2.1.0 +----- + +* Updated from global requirements +* Updated from global requirements +* Updated from global requirements +* Trival: Remove 'MANIFEST.in' + 2.0.0 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/MANIFEST.in new/oslotest-2.8.0/MANIFEST.in --- old/oslotest-2.0.0/MANIFEST.in 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/MANIFEST.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +0,0 @@ -include AUTHORS -include ChangeLog -exclude .gitignore -exclude .gitreview - -global-exclude *.pyc \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/PKG-INFO new/oslotest-2.8.0/PKG-INFO --- old/oslotest-2.0.0/PKG-INFO 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/PKG-INFO 2016-08-02 20:21:09.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: oslotest -Version: 2.0.0 +Version: 2.8.0 Summary: Oslo test framework Home-page: http://wiki.openstack.org/wiki/Oslo#oslotest Author: OpenStack @@ -30,3 +30,4 @@ Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/doc/source/features.rst new/oslotest-2.8.0/doc/source/features.rst --- old/oslotest-2.0.0/doc/source/features.rst 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/doc/source/features.rst 2016-08-02 20:18:37.000000000 +0200 @@ -37,7 +37,7 @@ [testenv:debug] commands = oslo_debug_helper -t keystoneclient/tests {posargs} -Similarily, most ``oslo`` projects have the tests at the package level, it +Similarly, most ``oslo`` projects have the tests at the package level, it would have to pass in:: [testenv:debug] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest/base.py new/oslotest-2.8.0/oslotest/base.py --- old/oslotest-2.0.0/oslotest/base.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/base.py 2016-08-02 20:18:37.000000000 +0200 @@ -15,6 +15,8 @@ """Common utilities used in testing""" +import logging + import fixtures from oslotest import createfile from oslotest import log @@ -24,6 +26,8 @@ from six.moves import mock import testtools +LOG = logging.getLogger(__name__) + _TRUE_VALUES = ('True', 'true', '1', 'yes') _LOG_FORMAT = "%(levelname)8s [%(name)s] %(message)s" @@ -81,12 +85,23 @@ # low for comparing most dicts self.maxDiff = 10000 - # Ensure that the mock.patch.stopall cleanup is registered - # before any setUp() methods have a chance to register other - # things to be cleaned up, so it is called last. This allows - # tests to register their own cleanups with a mock.stop method - # so those mocks are not included in the stopall set. - self.addCleanup(mock.patch.stopall) + def addCleanup(self, function, *args, **kwargs): + # NOTE(dims): This is a hack for Mitaka. We'll need to undo this as + # early as possible in Newton and advertise that this hack will not + # be supported anymore. + if (hasattr(self, '_cleanups') and + isinstance(self._cleanups, list)): + if not self._cleanups: + # Ensure that the mock.patch.stopall cleanup is registered + # before any addCleanup() methods have a chance to register + # other things to be cleaned up, so it is called last. This + # allows tests to register their own cleanups with a mock.stop + # method so those mocks are not included in the stopall set. + super(BaseTestCase, self).addCleanup(mock.patch.stopall) + else: + LOG.error('Unable to patch test case. ' + 'mock.patch.stopall cleanup was not registered.') + super(BaseTestCase, self).addCleanup(function, *args, **kwargs) def setUp(self): super(BaseTestCase, self).setUp() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest/mockpatch.py new/oslotest-2.8.0/oslotest/mockpatch.py --- old/oslotest-2.0.0/oslotest/mockpatch.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/mockpatch.py 2016-08-02 20:18:37.000000000 +0200 @@ -14,76 +14,22 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +"""Deprecated. + +This module is deprecated since version 1.13 and may be removed in version 2.0. +Use fixtures.Mock* classes instead. + +""" from debtcollector import removals import fixtures -from six.moves import mock removals.removed_module("oslotest.mockpatch", replacement="fixtures", version="1.13", removal_version="2.0", - message="Use fixtures.Mock* classes instead") - - -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 :func:`mock.patch.object`. - - .. py:attribute:: mock - - The mock as returned by :func:`mock.patch.object`. - - """ - - def __init__(self, obj, attr, new=mock.DEFAULT, **kwargs): - super(PatchObject, self).__init__() - self._get_p = lambda: mock.patch.object(obj, attr, new, **kwargs) - - -class Patch(_Base): - """Deal with code around :func:`mock.patch`. - - .. py:attribute:: mock - - The mock as returned by :func:`mock.patch`. - - """ - - def __init__(self, obj, new=mock.DEFAULT, **kwargs): - super(Patch, self).__init__() - self._get_p = lambda: mock.patch(obj, new, **kwargs) - - -class Multiple(_Base): - """Deal with code around :func:`mock.patch.multiple`. - - Pass name=value to replace obj.name with value. - - Pass name= :attr:`.DEFAULT` to replace obj.name with a - :class:`mock.MagicMock` instance. - - :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. - - .. py:attribute:: mock - - A :class:`dict`, where each key matches a kwarg parameter and the value - is the passed-in value or :class:`mock.MagicMock`. - - """ + message="Use fixtures.Mock* classes instead.") - DEFAULT = mock.DEFAULT - """Triggers a :class:`mock.MagicMock` to be created for the named - attribute.""" - def __init__(self, obj, **kwargs): - super(Multiple, self).__init__() - self._get_p = lambda: mock.patch.multiple(obj, **kwargs) +PatchObject = fixtures.MockPatchObject +Patch = fixtures.MockPatch +Multiple = fixtures.MockPatchMultiple diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest/tests/__init__.py new/oslotest-2.8.0/oslotest/tests/__init__.py --- old/oslotest-2.0.0/oslotest/tests/__init__.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/__init__.py 2016-08-02 20:18:37.000000000 +0200 @@ -0,0 +1,16 @@ +# 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 six + + +six.add_move(six.MovedModule('mock', 'mock', 'unittest.mock')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest/tests/unit/test_base.py new/oslotest-2.8.0/oslotest/tests/unit/test_base.py --- old/oslotest-2.0.0/oslotest/tests/unit/test_base.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/unit/test_base.py 2016-08-02 20:18:37.000000000 +0200 @@ -0,0 +1,192 @@ +# -*- 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 +import os +import unittest + +import six +from six.moves import mock +import testtools + +from oslotest import base +from oslotest import mockpatch + + +class TestBaseTestCase(testtools.TestCase): + + class FakeTestCase(base.BaseTestCase): + def test_fake_test(self): + pass + + @mock.patch('os.environ.get') + @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 + tc = self.FakeTestCase("test_fake_test") + tc._set_timeout() + env_get_mock.assert_called_once_with('OS_TEST_TIMEOUT', 0) + fixture_timeout_mock.assert_called_once_with(1, gentle=True) + self.assertEqual(1, fixture_mock.call_count) + + @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) + tc = self.FakeTestCase("test_fake_test") + tc.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + 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, default=None: { + 'OS_DEBUG': 'True', 'OS_LOG_CAPTURE': 0}.get(value, default) + tc = self.FakeTestCase("test_fake_test") + tc.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=base._LOG_FORMAT, + level=logging.DEBUG) + + @mock.patch('os.environ.get') + @mock.patch.object(FakeTestCase, 'useFixture') + def test_fake_logs_with_log_cap(self, fixture_mock, env_get_mock): + env_get_mock.side_effect = lambda value: {'OS_DEBUG': 0, + 'OS_LOG_CAPTURE': 'True' + }[value] + tc = self.FakeTestCase("test_fake_test") + tc.setUp() + env_get_mock.assert_any_call('OS_LOG_CAPTURE') + env_get_mock.assert_any_call('OS_DEBUG') + self.assertEqual(5, fixture_mock.call_count) + + def test_mock_patch_cleanup_on_teardown(self): + # create an object and save its reference + class Sub(object): + pass + + obj = Sub() + obj.value = obj.backup = object() + + # patch the object + mock.patch.object(obj, 'value').start() + self.assertNotEqual(obj.backup, obj.value) + + # run a test case + loader = unittest.defaultTestLoader + suite = loader.loadTestsFromTestCase(self.FakeTestCase) + suite.run(unittest.TestResult()) + + # check that mock patches are cleaned up + self.assertEqual(obj.backup, obj.value) + + @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): + + def setUp(self): + # Create a cleanup to undo a patch() call *before* calling the + # base class version of setup(). + patcher = mock.patch('os.environ.keys') + patcher.start() + self.addCleanup(patcher.stop) + super(TestManualMock, self).setUp() + self.useFixture(mockpatch.Patch('fixtures.Timeout')) + self.unstopped = mock.patch('os.environ.put') + + def tearDown(self): + super(TestManualMock, self).tearDown() + self.assertRaises( + RuntimeError, + self.unstopped.stop, + ) + + def test_mock_patch_manually(self): + # Verify that if a test instance creates its own mock and + # calls start/stop itself we don't get an error. + patcher = mock.patch('os.environ.get') + patcher.start() + self.addCleanup(patcher.stop) + + +class TestTempFiles(base.BaseTestCase): + def test_create_unicode_files(self): + files = [["no_approve", u'ಠ_ಠ']] + temps = self.create_tempfiles(files) + self.assertEqual(1, len(temps)) + with open(temps[0], 'rb') as f: + contents = f.read() + self.assertEqual(u'ಠ_ಠ', six.text_type(contents, encoding='utf-8')) + + def test_create_unicode_files_encoding(self): + files = [["embarrassed", u'⊙﹏⊙', 'utf-8']] + temps = self.create_tempfiles(files) + self.assertEqual(1, len(temps)) + with open(temps[0], 'rb') as f: + contents = f.read() + self.assertEqual(u'⊙﹏⊙', six.text_type(contents, encoding='utf-8')) + + def test_create_unicode_files_multi_encoding(self): + files = [ + ["embarrassed", u'⊙﹏⊙', 'utf-8'], + ['abc', 'abc', 'ascii'], + ] + temps = self.create_tempfiles(files) + self.assertEqual(2, len(temps)) + for i, (basename, raw_contents, raw_encoding) in enumerate(files): + with open(temps[i], 'rb') as f: + contents = f.read() + if not isinstance(raw_contents, six.text_type): + raw_contents = six.text_type(raw_contents, + encoding=raw_encoding) + self.assertEqual(six.text_type(contents, encoding=raw_encoding), + raw_contents) + + def test_create_bad_encoding(self): + files = [["hrm", u'ಠ~ಠ', 'ascii']] + self.assertRaises(UnicodeError, self.create_tempfiles, files) + + def test_prefix(self): + files = [["testing", '']] + temps = self.create_tempfiles(files) + self.assertEqual(1, len(temps)) + basename = os.path.basename(temps[0]) + self.assertTrue(basename.startswith('testing')) + + def test_wrong_length(self): + files = [["testing"]] + self.assertRaises(ValueError, self.create_tempfiles, files) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest/tests/unit/test_createfile.py new/oslotest-2.8.0/oslotest/tests/unit/test_createfile.py --- old/oslotest-2.0.0/oslotest/tests/unit/test_createfile.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/unit/test_createfile.py 2016-08-02 20:18:37.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-2.0.0/oslotest/tests/unit/test_log.py new/oslotest-2.8.0/oslotest/tests/unit/test_log.py --- old/oslotest-2.0.0/oslotest/tests/unit/test_log.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/unit/test_log.py 2016-08-02 20:18:37.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-2.0.0/oslotest/tests/unit/test_mockpatch.py new/oslotest-2.8.0/oslotest/tests/unit/test_mockpatch.py --- old/oslotest-2.0.0/oslotest/tests/unit/test_mockpatch.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/unit/test_mockpatch.py 2016-08-02 20:18:37.000000000 +0200 @@ -0,0 +1,26 @@ +# Copyright 2014 IBM Corp. +# +# 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. + + +from oslotest import base +from oslotest import mockpatch + + +class TestMockPatchSymbols(base.BaseTestCase): + def test_reference(self): + # Applications expect these public symbols to be available until the + # deprecated module is removed. + self.assertTrue(mockpatch.PatchObject) + self.assertTrue(mockpatch.Patch) + self.assertTrue(mockpatch.Multiple) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest/tests/unit/test_moxstubout.py new/oslotest-2.8.0/oslotest/tests/unit/test_moxstubout.py --- old/oslotest-2.0.0/oslotest/tests/unit/test_moxstubout.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/unit/test_moxstubout.py 2016-08-02 20:18:37.000000000 +0200 @@ -0,0 +1,33 @@ +# Copyright 2014 IBM Corp. +# +# 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. + +from oslotest import base +from oslotest import moxstubout + + +class TestMoxStubout(base.BaseTestCase): + + def _stubable(self): + pass + + def test_basic_stubout(self): + f = self.useFixture(moxstubout.MoxStubout()) + before = TestMoxStubout._stubable + f.mox.StubOutWithMock(TestMoxStubout, '_stubable') + after = TestMoxStubout._stubable + self.assertNotEqual(before, after) + f.cleanUp() + after2 = TestMoxStubout._stubable + self.assertEqual(before, after2) + f._clear_cleanups() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest/tests/unit/test_output.py new/oslotest-2.8.0/oslotest/tests/unit/test_output.py --- old/oslotest-2.0.0/oslotest/tests/unit/test_output.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/unit/test_output.py 2016-08-02 20:18:39.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 + +from six.moves 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-2.0.0/oslotest/tests/unit/test_timeout.py new/oslotest-2.8.0/oslotest/tests/unit/test_timeout.py --- old/oslotest-2.0.0/oslotest/tests/unit/test_timeout.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslotest-2.8.0/oslotest/tests/unit/test_timeout.py 2016-08-02 20:18:39.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. + +from six.moves 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(1, fixture_mock.call_count) + + @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(0, fixture_timeout_mock.call_count) + self.assertEqual(0, fixture_mock.call_count) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest.egg-info/PKG-INFO new/oslotest-2.8.0/oslotest.egg-info/PKG-INFO --- old/oslotest-2.0.0/oslotest.egg-info/PKG-INFO 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/oslotest.egg-info/PKG-INFO 2016-08-02 20:21:09.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: oslotest -Version: 2.0.0 +Version: 2.8.0 Summary: Oslo test framework Home-page: http://wiki.openstack.org/wiki/Oslo#oslotest Author: OpenStack @@ -30,3 +30,4 @@ Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest.egg-info/SOURCES.txt new/oslotest-2.8.0/oslotest.egg-info/SOURCES.txt --- old/oslotest-2.0.0/oslotest.egg-info/SOURCES.txt 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/oslotest.egg-info/SOURCES.txt 2016-08-02 20:21:09.000000000 +0200 @@ -6,7 +6,6 @@ ChangeLog HACKING.rst LICENSE -MANIFEST.in README.rst requirements.txt setup.cfg @@ -39,17 +38,17 @@ oslotest.egg-info/pbr.json oslotest.egg-info/requires.txt oslotest.egg-info/top_level.txt +oslotest/tests/__init__.py +oslotest/tests/unit/__init__.py +oslotest/tests/unit/test_base.py +oslotest/tests/unit/test_createfile.py +oslotest/tests/unit/test_log.py +oslotest/tests/unit/test_mockpatch.py +oslotest/tests/unit/test_moxstubout.py +oslotest/tests/unit/test_output.py +oslotest/tests/unit/test_timeout.py oslotest/tools/__init__.py oslotest/tools/config.py -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-2.0.0/oslotest.egg-info/pbr.json new/oslotest-2.8.0/oslotest.egg-info/pbr.json --- old/oslotest-2.0.0/oslotest.egg-info/pbr.json 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/oslotest.egg-info/pbr.json 2016-08-02 20:21:09.000000000 +0200 @@ -1 +1 @@ -{"is_release": true, "git_version": "4dbb9e2"} \ No newline at end of file +{"is_release": true, "git_version": "425d465"} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/oslotest.egg-info/requires.txt new/oslotest-2.8.0/oslotest.egg-info/requires.txt --- old/oslotest-2.0.0/oslotest.egg-info/requires.txt 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/oslotest.egg-info/requires.txt 2016-08-02 20:21:09.000000000 +0200 @@ -1,10 +1,10 @@ -fixtures>=1.3.1 +fixtures>=3.0.0 python-subunit>=0.0.18 six>=1.9.0 testrepository>=0.0.18 testscenarios>=0.4 testtools>=1.4.0 -mock>=1.2 +mock>=2.0 mox3>=0.7.0 -os-client-config!=1.6.2,>=1.4.0 -debtcollector>=0.3.0 +os-client-config>=1.13.1 +debtcollector>=1.2.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/requirements.txt new/oslotest-2.8.0/requirements.txt --- old/oslotest-2.0.0/requirements.txt 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/requirements.txt 2016-08-02 20:18:37.000000000 +0200 @@ -2,13 +2,13 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -fixtures>=1.3.1 -python-subunit>=0.0.18 -six>=1.9.0 -testrepository>=0.0.18 -testscenarios>=0.4 -testtools>=1.4.0 -mock>=1.2 -mox3>=0.7.0 -os-client-config!=1.6.2,>=1.4.0 -debtcollector>=0.3.0 # Apache-2.0 +fixtures>=3.0.0 # Apache-2.0/BSD +python-subunit>=0.0.18 # Apache-2.0/BSD +six>=1.9.0 # MIT +testrepository>=0.0.18 # Apache-2.0/BSD +testscenarios>=0.4 # Apache-2.0/BSD +testtools>=1.4.0 # MIT +mock>=2.0 # BSD +mox3>=0.7.0 # Apache-2.0 +os-client-config>=1.13.1 # Apache-2.0 +debtcollector>=1.2.0 # Apache-2.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/setup.cfg new/oslotest-2.8.0/setup.cfg --- old/oslotest-2.0.0/setup.cfg 2015-11-23 21:59:43.000000000 +0100 +++ new/oslotest-2.8.0/setup.cfg 2016-08-02 20:21:09.000000000 +0200 @@ -17,6 +17,7 @@ Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 [files] packages = @@ -43,6 +44,6 @@ [egg_info] tag_build = -tag_svn_revision = 0 tag_date = 0 +tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/test-requirements.txt new/oslotest-2.8.0/test-requirements.txt --- old/oslotest-2.0.0/test-requirements.txt 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/test-requirements.txt 2016-08-02 20:18:37.000000000 +0200 @@ -7,9 +7,9 @@ # when we can require tox>= 1.4, this can go into tox.ini: # [testenv:cover] # deps = {[testenv]deps} coverage -coverage>=3.6 +coverage>=3.6 # Apache-2.0 # this is required for the docs build jobs -sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +sphinx!=1.3b1,<1.3,>=1.2.1 # BSD oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 -oslo.config>=2.7.0 # Apache-2.0 +oslo.config>=3.12.0 # Apache-2.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/tests/__init__.py new/oslotest-2.8.0/tests/__init__.py --- old/oslotest-2.0.0/tests/__init__.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/__init__.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,16 +0,0 @@ -# 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 six - - -six.add_move(six.MovedModule('mock', 'mock', 'unittest.mock')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/tests/unit/test_base.py new/oslotest-2.8.0/tests/unit/test_base.py --- old/oslotest-2.0.0/tests/unit/test_base.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/unit/test_base.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,192 +0,0 @@ -# -*- 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 -import os -import unittest - -import six -from six.moves import mock -import testtools - -from oslotest import base -from oslotest import mockpatch - - -class TestBaseTestCase(testtools.TestCase): - - class FakeTestCase(base.BaseTestCase): - def test_fake_test(self): - pass - - @mock.patch('os.environ.get') - @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 - tc = self.FakeTestCase("test_fake_test") - tc._set_timeout() - 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') - 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) - tc = self.FakeTestCase("test_fake_test") - tc.setUp() - env_get_mock.assert_any_call('OS_LOG_CAPTURE') - 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, default=None: { - 'OS_DEBUG': 'True', 'OS_LOG_CAPTURE': 0}.get(value, default) - tc = self.FakeTestCase("test_fake_test") - tc.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=base._LOG_FORMAT, - level=logging.DEBUG) - - @mock.patch('os.environ.get') - @mock.patch.object(FakeTestCase, 'useFixture') - def test_fake_logs_with_log_cap(self, fixture_mock, env_get_mock): - env_get_mock.side_effect = lambda value: {'OS_DEBUG': 0, - 'OS_LOG_CAPTURE': 'True' - }[value] - tc = self.FakeTestCase("test_fake_test") - tc.setUp() - env_get_mock.assert_any_call('OS_LOG_CAPTURE') - 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 - class Sub(object): - pass - - obj = Sub() - obj.value = obj.backup = object() - - # patch the object - mock.patch.object(obj, 'value').start() - self.assertNotEqual(obj.value, obj.backup) - - # run a test case - loader = unittest.defaultTestLoader - suite = loader.loadTestsFromTestCase(self.FakeTestCase) - suite.run(unittest.TestResult()) - - # 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): - - def setUp(self): - # Create a cleanup to undo a patch() call *before* calling the - # base class version of setup(). - patcher = mock.patch('os.environ.keys') - patcher.start() - self.addCleanup(patcher.stop) - super(TestManualMock, self).setUp() - self.useFixture(mockpatch.Patch('fixtures.Timeout')) - self.unstopped = mock.patch('os.environ.put') - - def tearDown(self): - super(TestManualMock, self).tearDown() - self.assertRaises( - RuntimeError, - self.unstopped.stop, - ) - - def test_mock_patch_manually(self): - # Verify that if a test instance creates its own mock and - # calls start/stop itself we don't get an error. - patcher = mock.patch('os.environ.get') - patcher.start() - self.addCleanup(patcher.stop) - - -class TestTempFiles(base.BaseTestCase): - def test_create_unicode_files(self): - files = [["no_approve", u'ಠ_ಠ']] - temps = self.create_tempfiles(files) - self.assertEqual(1, len(temps)) - with open(temps[0], 'rb') as f: - contents = f.read() - self.assertEqual(u'ಠ_ಠ', six.text_type(contents, encoding='utf-8')) - - def test_create_unicode_files_encoding(self): - files = [["embarrassed", u'⊙﹏⊙', 'utf-8']] - temps = self.create_tempfiles(files) - self.assertEqual(1, len(temps)) - with open(temps[0], 'rb') as f: - contents = f.read() - self.assertEqual(u'⊙﹏⊙', six.text_type(contents, encoding='utf-8')) - - def test_create_unicode_files_multi_encoding(self): - files = [ - ["embarrassed", u'⊙﹏⊙', 'utf-8'], - ['abc', 'abc', 'ascii'], - ] - temps = self.create_tempfiles(files) - self.assertEqual(2, len(temps)) - for i, (basename, raw_contents, raw_encoding) in enumerate(files): - with open(temps[i], 'rb') as f: - contents = f.read() - if not isinstance(raw_contents, six.text_type): - raw_contents = six.text_type(raw_contents, - encoding=raw_encoding) - self.assertEqual(raw_contents, - six.text_type(contents, encoding=raw_encoding)) - - def test_create_bad_encoding(self): - files = [["hrm", u'ಠ~ಠ', 'ascii']] - self.assertRaises(UnicodeError, self.create_tempfiles, files) - - def test_prefix(self): - files = [["testing", '']] - temps = self.create_tempfiles(files) - self.assertEqual(1, len(temps)) - basename = os.path.basename(temps[0]) - self.assertTrue(basename.startswith('testing')) - - def test_wrong_length(self): - files = [["testing"]] - self.assertRaises(ValueError, self.create_tempfiles, files) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/tests/unit/test_createfile.py new/oslotest-2.8.0/tests/unit/test_createfile.py --- old/oslotest-2.0.0/tests/unit/test_createfile.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/unit/test_createfile.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,62 +0,0 @@ -# -*- 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-2.0.0/tests/unit/test_log.py new/oslotest-2.8.0/tests/unit/test_log.py --- old/oslotest-2.0.0/tests/unit/test_log.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/unit/test_log.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,100 +0,0 @@ -# -*- 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-2.0.0/tests/unit/test_mockpatch.py new/oslotest-2.8.0/tests/unit/test_mockpatch.py --- old/oslotest-2.0.0/tests/unit/test_mockpatch.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/unit/test_mockpatch.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,67 +0,0 @@ -# Copyright 2014 IBM Corp. -# -# 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. - - -from six.moves import mock - -from oslotest import base -from oslotest import mockpatch - - -class Foo(object): - def bar(self): - pass - - -def mocking_bar(self): - return 'mocked!' - - -class TestMockPatch(base.BaseTestCase): - def test_mock_patch_with_replacement(self): - self.useFixture(mockpatch.Patch('%s.Foo.bar' % (__name__), - mocking_bar)) - instance = Foo() - self.assertEqual(instance.bar(), 'mocked!') - - def test_mock_patch_without_replacement(self): - self.useFixture(mockpatch.Patch('%s.Foo.bar' % (__name__))) - instance = Foo() - self.assertIsInstance(instance.bar(), mock.MagicMock) - - -class TestMockMultiple(base.BaseTestCase): - def test_mock_multiple_with_replacement(self): - self.useFixture(mockpatch.Multiple('%s.Foo' % (__name__), - bar=mocking_bar)) - instance = Foo() - self.assertEqual(instance.bar(), 'mocked!') - - def test_mock_patch_without_replacement(self): - self.useFixture(mockpatch.Multiple('%s.Foo' % (__name__), - bar=mockpatch.Multiple.DEFAULT)) - instance = Foo() - self.assertIsInstance(instance.bar(), mock.MagicMock) - - -class TestMockPatchObject(base.BaseTestCase): - def test_mock_patch_object_with_replacement(self): - self.useFixture(mockpatch.PatchObject(Foo, 'bar', mocking_bar)) - instance = Foo() - self.assertEqual(instance.bar(), 'mocked!') - - def test_mock_patch_object_without_replacement(self): - self.useFixture(mockpatch.PatchObject(Foo, 'bar')) - instance = Foo() - self.assertIsInstance(instance.bar(), mock.MagicMock) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/tests/unit/test_moxstubout.py new/oslotest-2.8.0/tests/unit/test_moxstubout.py --- old/oslotest-2.0.0/tests/unit/test_moxstubout.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/unit/test_moxstubout.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,33 +0,0 @@ -# Copyright 2014 IBM Corp. -# -# 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. - -from oslotest import base -from oslotest import moxstubout - - -class TestMoxStubout(base.BaseTestCase): - - def _stubable(self): - pass - - def test_basic_stubout(self): - f = self.useFixture(moxstubout.MoxStubout()) - before = TestMoxStubout._stubable - f.mox.StubOutWithMock(TestMoxStubout, '_stubable') - after = TestMoxStubout._stubable - self.assertNotEqual(before, after) - f.cleanUp() - after2 = TestMoxStubout._stubable - self.assertEqual(before, after2) - f._clear_cleanups() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslotest-2.0.0/tests/unit/test_output.py new/oslotest-2.8.0/tests/unit/test_output.py --- old/oslotest-2.0.0/tests/unit/test_output.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/unit/test_output.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -# -*- 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-2.0.0/tests/unit/test_timeout.py new/oslotest-2.8.0/tests/unit/test_timeout.py --- old/oslotest-2.0.0/tests/unit/test_timeout.py 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tests/unit/test_timeout.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,45 +0,0 @@ -# -*- 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-2.0.0/tox.ini new/oslotest-2.8.0/tox.ini --- old/oslotest-2.0.0/tox.ini 2015-11-23 21:59:20.000000000 +0100 +++ new/oslotest-2.8.0/tox.ini 2016-08-02 20:18:37.000000000 +0200 @@ -1,6 +1,6 @@ [tox] distribute = False -envlist = py34,py27,pep8 +envlist = py35,py34,py27,pep8 [testenv] deps = -r{toxinidir}/test-requirements.txt
