Commit d34bb94d authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

chore([py2]): remove py2 support

--HG--
branch : 0.1
parent 410adfc4c9fc
......@@ -16,7 +16,6 @@ web = 'http://www.cubicweb.org/project/%s' % distname
__depends__ = {
'cubicweb[pyramid]': '>= 3.28.2',
'six': '>= 1.4.0',
'jsonschema': None,
'jsl': None,
'pyramid': '>= 1.10.0',
......
......@@ -17,8 +17,6 @@
"""cubicweb-jsonschema Pyramid views for the JSON API of entities."""
import json
from six import PY3
from pyramid import httpexceptions
from pyramid.renderers import render
from pyramid.view import view_config
......@@ -347,9 +345,7 @@ def generic_error(exc, request):
if isinstance(exc, httpexceptions.HTTPException):
if exc.content_type != 'application/json':
exc.content_type = 'application/json'
body = json.dumps({'message': exc.detail})
if PY3:
body = body.encode('utf-8')
body = json.dumps({'message': exc.detail}).encode('utf-8')
exc.body = body
return exc
request.cw_cnx.rollback()
......
......@@ -7,7 +7,6 @@ import re
import unittest
import jsondiff
from six import string_types
class ParseError(Exception):
......@@ -141,7 +140,7 @@ def _jsondiff_filter_ellipsis(diffobj):
break
else:
del diffobj[key]
elif isinstance(want, string_types):
elif isinstance(want, str):
if doctest._ellipsis_match(want, got):
del diffobj[key]
......
......@@ -16,8 +16,6 @@
"""cubicweb-jsonschema Pyramid "entities" resources definitions."""
from six import text_type
from pyramid.decorator import reify
from pyramid.httpexceptions import HTTPNotFound
......@@ -174,7 +172,7 @@ class RelatedEntityResource(object):
self.rtype = rtype
self.role = role
self.__parent__ = parent
self.__name__ = text_type(entity.eid)
self.__name__ = str(entity.eid)
@reify
def described_by(self):
......
......@@ -22,7 +22,6 @@ from unittest import skip
import jsonschema
from mock import patch
from six import PY2
from cubicweb import Binary, ValidationError
from cubicweb.pyramid.test import PyramidCWTest
......@@ -278,10 +277,7 @@ class EntitiesTC(BaseTC):
headers={'Accept': 'application/json'})
errors = res.json_body['errors']
# See https://github.com/Julian/jsonschema/issues/243
if PY2:
hint = "u'born' was unexpected"
else:
hint = "'born' was unexpected"
hint = "'born' was unexpected"
expected = [{'status': 422,
'details': ("Additional properties are not allowed "
"(%s)" % hint)}]
......
......@@ -19,8 +19,6 @@
from base64 import b64encode
from copy import deepcopy
from six import text_type
from cubicweb import ValidationError
from cubicweb.devtools.testlib import CubicWebTC
......@@ -112,7 +110,7 @@ class IJSONSchemaETypeAdapterTC(CubicWebTC):
user_creation_schema = creation_schema['properties']
expected_items = {
'type': 'string',
'oneOf': [{'enum': [text_type(eid)], 'title': title}
'oneOf': [{'enum': [str(eid)], 'title': title}
for eid, title in groups],
}
self.assertEqual(user_creation_schema['in_group']['items'],
......@@ -298,7 +296,7 @@ class IJSONSchemaEntityAdapterTC(CubicWebTC):
users = cnx.find('CWGroup', name=u'users').one()
adapter = jsonschema_adapter(cnx, etype='CWUser')
instance = {'login': 'bob', 'upassword': 'sponge',
'in_group': [text_type(users.eid)],
'in_group': [str(users.eid)],
'use_email': [{'address': 'bob@sponge.com'}]}
entity = adapter.create_entity(instance)
self.assertEqual(entity.login, 'bob')
......@@ -317,7 +315,7 @@ class IJSONSchemaEntityAdapterTC(CubicWebTC):
adapter = jsonschema_adapter(cnx, entity=entity)
instance = {'login': 'bobby',
'in_group': [text_type(users.eid)],
'in_group': [str(users.eid)],
'use_email': [{'address': 'bob@sponge.com'}]}
adapter.edit_entity(instance)
entity.cw_clear_all_caches()
......@@ -331,8 +329,8 @@ class IJSONSchemaEntityAdapterTC(CubicWebTC):
self.assertEqual(entity.use_email[0].address, 'bob@sponge.com')
instance = {'login': 'bobby',
'in_group': [text_type(users.eid),
text_type(guests.eid)],
'in_group': [str(users.eid),
str(guests.eid)],
'use_email': [{'address': 'bobby@sponge.com'}]}
adapter.edit_entity(instance)
entity.cw_clear_all_caches()
......@@ -344,7 +342,7 @@ class IJSONSchemaEntityAdapterTC(CubicWebTC):
self.assertEqual(entity.use_email[0].address, 'bobby@sponge.com')
instance = {'login': 'bobby',
'in_group': [text_type(users.eid)],
'in_group': [str(users.eid)],
'use_email': [{'address': 'bobby@sponge.com'},
{'address': 'bob.sponge@sponge.com'}]}
adapter.edit_entity(instance)
......@@ -356,7 +354,7 @@ class IJSONSchemaEntityAdapterTC(CubicWebTC):
['bobby@sponge.com', 'bob.sponge@sponge.com'])
instance = {'login': 'bobby',
'in_group': [text_type(users.eid)],
'in_group': [str(users.eid)],
'use_email': [{'address': 'bob.sponge@sponge.com'}]}
adapter.edit_entity(instance)
entity.cw_clear_all_caches()
......@@ -366,7 +364,7 @@ class IJSONSchemaEntityAdapterTC(CubicWebTC):
entity.cw_set(use_email=cnx.create_entity('EmailAlias'))
instance = {'login': 'bobby',
'in_group': [text_type(users.eid)],
'in_group': [str(users.eid)],
'use_email': []}
adapter.edit_entity(instance)
entity.cw_clear_all_caches()
......@@ -385,7 +383,7 @@ class IJSONSchemaEntityAdapterTC(CubicWebTC):
email.cw_clear_all_caches()
groups = entity.related('in_group', 'subject').entities()
group_ids = [text_type(group.eid) for group in groups]
group_ids = [str(group.eid) for group in groups]
expected = {
u'firstname': u'Bob',
u'login': u'bob',
......
......@@ -16,8 +16,6 @@
"""cubicweb-jsonschema Yams to jsl unit tests."""
from six import text_type
from cubicweb.devtools.testlib import CubicWebTC
from cubicweb_jsonschema.views.y2jsl import y2j_etype
......@@ -77,7 +75,7 @@ class CWYams2JsonTC(CubicWebTC):
'state_of'], list(state_props))
expected_items = {
'type': 'string',
'oneOf': [{'enum': [text_type(userworkflow_eid)],
'oneOf': [{'enum': [str(userworkflow_eid)],
'title': u'default user workflow'}],
}
self.assertEqual(state_props['state_of']['items'],
......@@ -105,7 +103,7 @@ class CWYams2JsonTC(CubicWebTC):
expected_items = {
'type': 'string',
'oneOf': [
{'enum': [text_type(eid)], 'title': title}
{'enum': [str(eid)], 'title': title}
for eid, title in users],
}
self.assertEqual(properties['in_group']['items'],
......
[tox]
envlist = py27,py3,flake8,check-manifest
envlist = py3,flake8,check-manifest
[testenv]
deps =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment