summaryrefslogtreecommitdiff
path: root/oslo
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-08-08 23:13:55 +0100
committerMark McLoughlin <markmc@redhat.com>2013-10-21 12:01:08 +0100
commitbcb309604185502bbc0f16a395abf8081bd7ae22 (patch)
tree16fa75c078f36ed737f2b601e4d603447e9d7cbe /oslo
parent464efedfdd68c1a1ed4dae6fdb01bbce9c34b8da (diff)
downloadoslo-version-bcb309604185502bbc0f16a395abf8081bd7ae22.tar.gz
Make the tests actually run
Firstly, add a missing oslo/version/__init__.py. Secondly, move tests from oslo/version/tests/ to tests/ Having the tests under oslo.version and using oslo.sphinx in the same virtual env doesn't seem to work. The issue appears to be that because the tests don't get installed under the namespace package in the venv's site-packages, testr can't find them. Personally, I'm a fan of keeping tests in a different directory from the runtime code and this is what works for oslo.config and oslo.messaging. Thirdly, avoid using 'setup.py develop' with tox. There seems to be an issue with the 'setup.py develop' approach caused by the fact that oslo is a namespace package and we install oslo.sphinx into this namespace in the virtualenv. This results in the oslo.version package not being found when it's not properly installed into the virtualenv. These really should be three separate commits, but any one of them alone causes testr to stop pretending everything is fine so they all need to be merged together. Closes-Bug: #1242614 Change-Id: I5140fa62dc8bdd10a58bd2847b27514a926e3c19
Diffstat (limited to 'oslo')
-rw-r--r--oslo/version/__init__.py15
-rw-r--r--oslo/version/tests/__init__.py55
-rw-r--r--oslo/version/tests/test_version.py60
3 files changed, 15 insertions, 115 deletions
diff --git a/oslo/version/__init__.py b/oslo/version/__init__.py
new file mode 100644
index 0000000..30ed0a7
--- /dev/null
+++ b/oslo/version/__init__.py
@@ -0,0 +1,15 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 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.
diff --git a/oslo/version/tests/__init__.py b/oslo/version/tests/__init__.py
deleted file mode 100644
index d850631..0000000
--- a/oslo/version/tests/__init__.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010-2011 OpenStack Foundation
-# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# 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.
-
-"""Common utilities used in testing"""
-
-__all__ = [
- 'BaseTestCase'
-]
-
-import os
-
-import fixtures
-import testresources
-import testtools
-
-_TRUE_VALUES = ('true', '1', 'yes')
-
-
-class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
-
- def setUp(self):
- super(BaseTestCase, self).setUp()
- test_timeout = os.environ.get('OS_TEST_TIMEOUT', 30)
- try:
- test_timeout = int(test_timeout)
- except ValueError:
- # If timeout value is invalid, fail hard.
- print("OS_TEST_TIMEOUT set to invalid value"
- " defaulting to no timeout")
- test_timeout = 0
- if test_timeout > 0:
- self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
-
- 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.useFixture(fixtures.NestedTempfile())
diff --git a/oslo/version/tests/test_version.py b/oslo/version/tests/test_version.py
deleted file mode 100644
index 09a70f5..0000000
--- a/oslo/version/tests/test_version.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 Red Hat, Inc.
-# Copyright 2012-2013 Hewlett-Packard Development Company, L.P.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# 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
-
-from oslo.version import tests
-from oslo.version import version
-
-
-class DeferredVersionTestCase(tests.BaseTestCase):
-
- def test_cached_version(self):
- class MyVersionInfo(version.VersionInfo):
- def _get_version_from_pkg_resources(self):
- return "5.5.5.5"
-
- deferred_string = MyVersionInfo("openstack").\
- cached_version_string()
- self.assertEqual("5.5.5.5", deferred_string)
-
-
-class FindConfigFilesTestCase(tests.BaseTestCase):
-
- def _monkey_patch(self, config_files):
- self.useFixture(fixtures.MonkeyPatch('sys.argv', ['foo']))
- self.useFixture(fixtures.MonkeyPatch('os.path.exists',
- lambda p: p in config_files))
-
- def test_find_config_files(self):
- config_files = [os.path.expanduser('~/.blaa/blaa.conf'),
- '/etc/foo.conf']
- self._monkey_patch(config_files)
-
- self.assertEqual(
- config_files, version._find_config_files(project='blaa'))
-
- def test_find_config_files_with_extension(self):
- config_files = ['/etc/foo.json']
- self._monkey_patch(config_files)
-
- self.assertEqual([], version._find_config_files(project='blaa'))
- self.assertEqual(config_files,
- version._find_config_files(project='blaa',
- extension='.json'))