More python3 compatibility.

* pbr/packaging.py: Properly convert bytes into unicode strings and back
to bytes again. Replace os.path.walk() with os.walk().

* pbr/tests/__init__.py: Remove use of mox.

* pbr/tests/moxstubout.py: Remove use of mox.

* pbr/tests/test_setup.py: Use bytestrings instead of str or unicode
when performing IO.

* pbr/tests/test_version.py: Remove use of oslo.config.

* requirements.txt: Pin jinja2 to version compatible with python3.2.

* test-requirements.txt: Remove oslo.config and mox.

Change-Id: I9b5a32d7204fa2af56ecf4fdcf6b6da3bbb03200
This commit is contained in:
Clark Boylan 2013-06-03 14:05:02 -07:00
parent 5e8d7b27fe
commit 184a6ef0a1
2 changed files with 1 additions and 47 deletions

View File

@ -23,7 +23,6 @@ import testresources
import testtools
from pbr import packaging
from pbr.tests import moxstubout
class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
@ -52,4 +51,3 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.FakeLogger())
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs

View File

@ -15,21 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
from d2to1.extern import six
from oslo.config import cfg
from pbr import tests
from pbr import version
class DeferredVersionTestCase(tests.BaseTestCase):
def setUp(self):
super(DeferredVersionTestCase, self).setUp()
self.conf = cfg.ConfigOpts()
def test_cached_version(self):
class MyVersionInfo(version.VersionInfo):
def _get_version_from_pkg_resources(self):
@ -37,39 +28,4 @@ class DeferredVersionTestCase(tests.BaseTestCase):
deferred_string = MyVersionInfo("openstack").\
cached_version_string()
self.conf([], project="project", prog="prog", version=deferred_string)
self.assertEquals("5.5.5.5", str(self.conf.version))
def test_print_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.stubs.Set(sys, 'stderr', six.StringIO())
self.assertRaises(SystemExit,
self.conf, ['--version'],
project="project",
prog="prog",
version=deferred_string)
self.assertEquals("5.5.5.5", sys.stderr.getvalue().strip())
def test_print_cached_version_with_long_string(self):
my_version = "11111222223333344444555556666677777888889999900000"
class MyVersionInfo(version.VersionInfo):
def _get_version_from_pkg_resources(self):
return my_version
deferred_string = MyVersionInfo("openstack")\
.cached_version_string()
for i in range(50):
self.stubs.Set(sys, 'stderr', six.StringIO())
self.assertRaises(SystemExit,
self.conf, ['--version'],
project="project",
prog="prog",
version=deferred_string)
self.assertEquals(my_version, sys.stderr.getvalue().strip())
self.assertEquals("5.5.5.5", deferred_string)