diff options
| author | Alessio Ababilov <aababilo@yahoo-inc.com> | 2013-03-28 14:21:13 +0200 |
|---|---|---|
| committer | Alessio Ababilov <aababilov@griddynamics.com> | 2013-03-28 21:30:01 +0200 |
| commit | b85439e57d0109938ee5d5eeb8906a6b052cb6a7 (patch) | |
| tree | c63a523b19c8a4ade2bb506c30a03225b5ed070e | |
| parent | f79915ec1d975219719e0ba99128d7c62398ae0a (diff) | |
| download | oslo-b85439e57d0109938ee5d5eeb8906a6b052cb6a7.tar.gz oslo-b85439e57d0109938ee5d5eeb8906a6b052cb6a7.tar.xz oslo-b85439e57d0109938ee5d5eeb8906a6b052cb6a7.zip | |
Fix test_write_git_changelog
The test changes current directory to a temporary one
and ChangeLog file is created here. That's why the file
doesn't reside in project's root directory.
The correct behavior is to look for ChangeLog at cwd as is
done in test_generate_authors for AUTHORS file.
Use openstack.common.setup.__file__ to determine the
root directory of openstack package.
Change-Id: Ic7c9b01485a08b8921c88ac624e0aecd9409fa7c
Fixes: bug #1161362
| -rw-r--r-- | tests/unit/test_setup.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/unit/test_setup.py b/tests/unit/test_setup.py index fecc1d2..ae19c98 100644 --- a/tests/unit/test_setup.py +++ b/tests/unit/test_setup.py @@ -87,13 +87,16 @@ class GitLogsTest(utils.BaseTestCase): @staticmethod def _root_dir(): - # NOTE(yamahata): get root direcotry of repository - # __file__ = $ROOT/tests/unit/test_setup.py - # => $ROOT/tests/unit => $ROOT/tests => $ROOT - root_dir = os.path.dirname(__file__) - root_dir = os.path.dirname(root_dir) - root_dir = os.path.dirname(root_dir) - return root_dir + # NOTE(yamahata): get root directory of repository + # NOTE(aababilov): use openstack.common.setup.__file__ + # because openstack/common/setup.py uses this + # variable to find the root. + # Do not use test_setup.__file__ variable because + # openstack package can be installed somewhere and + # its location will differ from tests' one. + import openstack.common.setup + return os.path.dirname(os.path.dirname(os.path.dirname( + openstack.common.setup.__file__))) def test_write_git_changelog(self): root_dir = self._root_dir() @@ -116,7 +119,7 @@ class GitLogsTest(utils.BaseTestCase): setup.write_git_changelog() - with open(os.path.join(root_dir, "ChangeLog"), "r") as ch_fh: + with open("ChangeLog", "r") as ch_fh: self.assertTrue("email@foo.com" in ch_fh.read()) def _fake_log_output(self, cmd, mapping): |
