diff options
author | efkin <efkin@riseup.net> | 2017-03-13 20:20:19 +0100 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-03-17 17:52:56 +0100 |
commit | ba3fcb08eafd389bdbf0ab9c59577a25c8d8126d (patch) | |
tree | 24f41600853a07318a035c5de4fc11f8e10fdd6a /testing | |
parent | 1034d3107b57f03d7ed2257aef39cede2f6686ef (diff) |
[test] Prepare tests for python3 compatibility
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test_soledad/u1db_tests/__init__.py | 9 | ||||
-rw-r--r-- | testing/test_soledad/u1db_tests/test_https.py | 2 | ||||
-rw-r--r-- | testing/test_soledad/util.py | 11 | ||||
-rw-r--r-- | testing/tests/client/test_deprecated_crypto.py | 3 | ||||
-rw-r--r-- | testing/tests/conftest.py | 2 | ||||
-rw-r--r-- | testing/tests/couch/common.py | 2 | ||||
-rw-r--r-- | testing/tests/couch/test_atomicity.py | 2 | ||||
-rw-r--r-- | testing/tests/couch/test_backend.py | 4 | ||||
-rw-r--r-- | testing/tests/couch/test_sync.py | 4 | ||||
-rw-r--r-- | testing/tests/couch/test_sync_target.py | 6 | ||||
-rw-r--r-- | testing/tests/server/test_server.py | 2 | ||||
-rw-r--r-- | testing/tests/server/test_session.py | 2 | ||||
-rw-r--r-- | testing/tests/sqlcipher/test_backend.py | 9 | ||||
-rw-r--r-- | testing/tests/sync/test_sync.py | 2 | ||||
-rw-r--r-- | testing/tests/sync/test_sync_mutex.py | 2 | ||||
-rw-r--r-- | testing/tests/sync/test_sync_target.py | 3 |
16 files changed, 39 insertions, 26 deletions
diff --git a/testing/test_soledad/u1db_tests/__init__.py b/testing/test_soledad/u1db_tests/__init__.py index ba776864..36db548d 100644 --- a/testing/test_soledad/u1db_tests/__init__.py +++ b/testing/test_soledad/u1db_tests/__init__.py @@ -23,11 +23,16 @@ import socket import tempfile import threading import json +import sys +from six import StringIO from wsgiref import simple_server -from pysqlcipher import dbapi2 -from StringIO import StringIO + +if sys.version_info[0] < 3: + from pysqlcipher import dbapi2 +else: + from pysqlcipher3 import dbapi2 import testscenarios from twisted.trial import unittest diff --git a/testing/test_soledad/u1db_tests/test_https.py b/testing/test_soledad/u1db_tests/test_https.py index baffa723..2e75afd1 100644 --- a/testing/test_soledad/u1db_tests/test_https.py +++ b/testing/test_soledad/u1db_tests/test_https.py @@ -84,7 +84,7 @@ class TestHttpSyncTargetHttpsSupport(tests.TestCaseWithServer): remote_target = self.getSyncTarget('localhost', 'test') try: remote_target.record_sync_info('other-id', 2, 'T-id') - except ssl.SSLError, e: + except ssl.SSLError as e: self.assertIn("certificate verify failed", str(e)) else: self.fail("certificate verification should have failed.") diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index 83a27016..91291faf 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -24,12 +24,17 @@ import random import string import couchdb import pytest +import sys +from six.moves.urllib.parse import urljoin +from six import StringIO from uuid import uuid4 from mock import Mock -from urlparse import urljoin -from StringIO import StringIO -from pysqlcipher import dbapi2 + +if sys.version_info[0] < 3: + from pysqlcipher import dbapi2 +else: + from pysqlcipher3 import dbapi2 from twisted.trial import unittest diff --git a/testing/tests/client/test_deprecated_crypto.py b/testing/tests/client/test_deprecated_crypto.py index 1af1a130..cdebcb3e 100644 --- a/testing/tests/client/test_deprecated_crypto.py +++ b/testing/tests/client/test_deprecated_crypto.py @@ -1,9 +1,8 @@ import json from pytest import inlineCallbacks - +from six.moves.urllib.parse import urljoin from uuid import uuid4 -from urlparse import urljoin from leap.soledad.client import crypto as old_crypto from leap.soledad.common.couch import CouchDatabase diff --git a/testing/tests/conftest.py b/testing/tests/conftest.py index c077828f..589cb7de 100644 --- a/testing/tests/conftest.py +++ b/testing/tests/conftest.py @@ -7,7 +7,7 @@ import time from hashlib import sha512 from subprocess import check_call -from urlparse import urljoin +from six.moves.urllib.parse import urljoin from uuid import uuid4 from leap.soledad.common.couch import CouchDatabase diff --git a/testing/tests/couch/common.py b/testing/tests/couch/common.py index 84790059..3c272f6e 100644 --- a/testing/tests/couch/common.py +++ b/testing/tests/couch/common.py @@ -1,5 +1,5 @@ from uuid import uuid4 -from urlparse import urljoin +from six.moves.urllib.parse import urljoin from couchdb.client import Server from leap.soledad.common import couch diff --git a/testing/tests/couch/test_atomicity.py b/testing/tests/couch/test_atomicity.py index a3ae0314..48e1c01d 100644 --- a/testing/tests/couch/test_atomicity.py +++ b/testing/tests/couch/test_atomicity.py @@ -21,7 +21,7 @@ import os import pytest import threading -from urlparse import urljoin +from six.moves.urllib.parse import urljoin from twisted.internet import defer from uuid import uuid4 diff --git a/testing/tests/couch/test_backend.py b/testing/tests/couch/test_backend.py index 4fad11cf..9dfa22ac 100644 --- a/testing/tests/couch/test_backend.py +++ b/testing/tests/couch/test_backend.py @@ -19,7 +19,7 @@ Test ObjectStore and Couch backend bits. """ from uuid import uuid4 -from urlparse import urljoin +from six.moves.urllib.parse import urljoin from testscenarios import TestWithScenarios from twisted.trial import unittest @@ -28,7 +28,7 @@ from leap.soledad.common import couch from test_soledad.util import CouchDBTestCase from test_soledad.u1db_tests import test_backends -from common import COUCH_SCENARIOS +from .common import COUCH_SCENARIOS # ----------------------------------------------------------------------------- diff --git a/testing/tests/couch/test_sync.py b/testing/tests/couch/test_sync.py index bccbfe43..c353518e 100644 --- a/testing/tests/couch/test_sync.py +++ b/testing/tests/couch/test_sync.py @@ -8,8 +8,8 @@ from test_soledad.util import CouchDBTestCase from test_soledad.util import sync_via_synchronizer from test_soledad.u1db_tests import DatabaseBaseTests -from common import simple_doc -from common import COUCH_SCENARIOS +from .common import simple_doc +from .common import COUCH_SCENARIOS sync_scenarios = [] diff --git a/testing/tests/couch/test_sync_target.py b/testing/tests/couch/test_sync_target.py index e792fb76..0370a6d1 100644 --- a/testing/tests/couch/test_sync_target.py +++ b/testing/tests/couch/test_sync_target.py @@ -10,9 +10,9 @@ from test_soledad.util import CouchDBTestCase from test_soledad.util import make_local_db_and_target from test_soledad.u1db_tests import DatabaseBaseTests -from common import simple_doc -from common import nested_doc -from common import COUCH_SCENARIOS +from .common import simple_doc +from .common import nested_doc +from .common import COUCH_SCENARIOS target_scenarios = [ diff --git a/testing/tests/server/test_server.py b/testing/tests/server/test_server.py index 4a5ec43f..bc80905e 100644 --- a/testing/tests/server/test_server.py +++ b/testing/tests/server/test_server.py @@ -21,7 +21,7 @@ import binascii import os import pytest -from urlparse import urljoin +from six.moves.urllib.parse import urljoin from uuid import uuid4 from twisted.internet import defer diff --git a/testing/tests/server/test_session.py b/testing/tests/server/test_session.py index ebb94476..1ca34f8a 100644 --- a/testing/tests/server/test_session.py +++ b/testing/tests/server/test_session.py @@ -156,7 +156,7 @@ class SoledadSessionTestCase(unittest.TestCase): return {} def decode(self, response, request): - print "decode raised" + print("decode raised") raise UnexpectedException() self.wrapper._credentialFactory = BadFactory() diff --git a/testing/tests/sqlcipher/test_backend.py b/testing/tests/sqlcipher/test_backend.py index caacba0d..643fa041 100644 --- a/testing/tests/sqlcipher/test_backend.py +++ b/testing/tests/sqlcipher/test_backend.py @@ -21,8 +21,11 @@ import os import pytest import time import threading - -from pysqlcipher import dbapi2 +import sys +if sys.version_info[0] < 3: + from pysqlcipher import dbapi2 +else: + from pysqlcipher3 import dbapi2 from testscenarios import TestWithScenarios # l2db stuff. @@ -148,7 +151,7 @@ class TestSQLCipherDatabase(tests.TestCase): def run(self): try: db2 = SQLCipherDatabaseTesting(dbname, 2) - except Exception, e: + except Exception as e: SecondTry.outcome2.append(e) else: SecondTry.outcome2.append(db2) diff --git a/testing/tests/sync/test_sync.py b/testing/tests/sync/test_sync.py index 76757c5b..bce20894 100644 --- a/testing/tests/sync/test_sync.py +++ b/testing/tests/sync/test_sync.py @@ -18,7 +18,7 @@ import json import threading import time -from urlparse import urljoin +from six.moves.urllib.parse import urljoin from mock import Mock from twisted.internet import defer diff --git a/testing/tests/sync/test_sync_mutex.py b/testing/tests/sync/test_sync_mutex.py index 432a3cd2..a9335973 100644 --- a/testing/tests/sync/test_sync_mutex.py +++ b/testing/tests/sync/test_sync_mutex.py @@ -25,7 +25,7 @@ be two concurrent synchronization processes at the same time. import time import uuid -from urlparse import urljoin +from six.moves.urllib.parse import urljoin from twisted.internet import defer diff --git a/testing/tests/sync/test_sync_target.py b/testing/tests/sync/test_sync_target.py index 25136ba1..a54a02ee 100644 --- a/testing/tests/sync/test_sync_target.py +++ b/testing/tests/sync/test_sync_target.py @@ -17,13 +17,14 @@ """ Test Leap backend bits: sync target """ -import cStringIO import os import time import json import random import string import shutil + +from six import StringIO as cStringIO from uuid import uuid4 from testscenarios import TestWithScenarios |