Fix for py33 unittest running

Rework some imports to work with py27 and py33, also fix unittests
for config schemas and version checking. This commit is not garantee
that application will fully worked on python3.3
Task:
https://blueprints.launchpad.net/rubick/+spec/python33-support

Signed-off-by: Peter Lomakin <plomakin@mirantis.com>

Change-Id: Iffa564d52fd2bf83cebe9f31cca74e27c0b6baad
This commit is contained in:
Peter Lomakin 2013-11-18 14:18:32 +04:00
parent 46c5ad5406
commit e492c06315
10 changed files with 54 additions and 19 deletions

View File

@ -17,7 +17,7 @@ from rubick.model import DirectoryResource
def indent_prefix(indent=0):
s = ''
if indent > 0:
for i in xrange(0, indent):
for i in range(0, indent):
s += ' '
return s

View File

@ -4,7 +4,11 @@ import os
from paramiko.dsskey import DSSKey
from paramiko.rsakey import RSAKey
import stat
from StringIO import StringIO
import sys
if sys.version < '3':
from StringIO import StringIO
else:
from io import StringIO
TMP_KEY_PATH = "/tmp/joker_%s_%d"

View File

@ -10,7 +10,8 @@ honcho==0.4.2
jinja2==2.7
lettuce>=0.2.19
pymongo==2.6.1
recordtype==1.1
#recordtype==1.1
https://bitbucket.org/jstasiak/recordtype/get/default.tar.gz
paramiko==1.11.0
oslo.config==1.2.1
requests==1.2.0

View File

@ -78,13 +78,40 @@ class Version:
return '<Version %s>' % str(self)
def __cmp__(self, other):
for i in xrange(0, 3):
for i in range(0, 3):
x = self.parts[i] - other.parts[i]
if x != 0:
return -1 if x < 0 else 1
return 0
def __lt__(self, other):
for i in range(0, 3):
x = self.parts[i] - other.parts[i]
if x != 0:
return True if x < 0 else False
return False
def __le__(self, other):
for i in range(0, 3):
x = self.parts[i] - other.parts[i]
if x != 0:
return True if x < 0 else False
return True
def __ne__(self, other):
for i in range(0, 3):
x = self.parts[i] - other.parts[i]
if x != 0:
return True
return False
def __eq__(self, other):
for i in range(0, 3):
x = self.parts[i] - other.parts[i]
if x != 0:
return False
return True
class Mark(object):

View File

@ -1,3 +1,2 @@
from common import *
from ini import IniConfigParser
from rubick.common import *
from rubick.config_formats.ini import IniConfigParser

View File

@ -1,5 +1,10 @@
import re
from StringIO import StringIO
import sys
if sys.version < '3':
from StringIO import StringIO
else:
from io import StringIO
from rubick.config_model import *
from rubick.config_formats.common import *

View File

@ -1,8 +1,8 @@
import unittest
from contextlib import contextmanager
from rubick.schema import ConfigSchemaRegistry, Version
from rubick.common import find
from rubick.schema import ConfigSchemaRegistry
from rubick.common import find, Version
class TestConfigSchemaLoader(object):

View File

@ -1,4 +1,4 @@
from rubick.schema import Version
from rubick.common import Version
import unittest

View File

@ -1,16 +1,11 @@
[tox]
minversion = 1.6
envlist = py26,py27,pep8
envlist = py26,py27,py33,pep8
skipsdist = True
[testenv]
sitepackages = True
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=C
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =

View File

@ -1,4 +1,8 @@
from StringIO import StringIO
import sys
if sys.version < '3':
from StringIO import StringIO
else:
from io import StringIO
from bson.objectid import ObjectId
import os.path