Show More
@@ -237,7 +237,7 b' class TestAdminSettingsGlobal(object):' | |||||
237 | app_settings = SettingsModel().get_all_settings() |
|
237 | app_settings = SettingsModel().get_all_settings() | |
238 | del settings['csrf_token'] |
|
238 | del settings['csrf_token'] | |
239 | for key, value in settings.items(): |
|
239 | for key, value in settings.items(): | |
240 |
assert app_settings[key] == value |
|
240 | assert app_settings[key] == value | |
241 |
|
241 | |||
242 | return response |
|
242 | return response | |
243 |
|
243 |
@@ -442,7 +442,7 b' class AdminSettingsView(BaseAppView):' | |||||
442 | 'repo_group/test_repo1', error_container=error_container) |
|
442 | 'repo_group/test_repo1', error_container=error_container) | |
443 | if error_container: |
|
443 | if error_container: | |
444 | def converter(inp): |
|
444 | def converter(inp): | |
445 |
return h.html_escape( |
|
445 | return h.html_escape(inp) | |
446 |
|
446 | |||
447 | return 'ERRORS: ' + '\n'.join(map(converter, error_container)) |
|
447 | return 'ERRORS: ' + '\n'.join(map(converter, error_container)) | |
448 |
|
448 |
@@ -81,8 +81,6 b' class SettingsMaker(object):' | |||||
81 |
|
81 | |||
82 | @classmethod |
|
82 | @classmethod | |
83 | def _bool_func(cls, input_val): |
|
83 | def _bool_func(cls, input_val): | |
84 | if isinstance(input_val, str): |
|
|||
85 | input_val = input_val.encode('utf8') |
|
|||
86 | return str2bool(input_val) |
|
84 | return str2bool(input_val) | |
87 |
|
85 | |||
88 | @classmethod |
|
86 | @classmethod |
@@ -273,7 +273,7 b' class WerkzeugAdapter(BaseAdapter):' | |||||
273 | self.response = response |
|
273 | self.response = response | |
274 |
|
274 | |||
275 | def write(self, value): |
|
275 | def write(self, value): | |
276 |
self.response.data = self.response.data |
|
276 | self.response.data = self.response.data + value | |
277 |
|
277 | |||
278 | def set_header(self, key, value): |
|
278 | def set_header(self, key, value): | |
279 | self.response.headers[key] = value |
|
279 | self.response.headers[key] = value |
@@ -1156,7 +1156,7 b' class Response(ReprMixin):' | |||||
1156 | if self.is_binary_string(content): |
|
1156 | if self.is_binary_string(content): | |
1157 | self._content = content |
|
1157 | self._content = content | |
1158 | else: |
|
1158 | else: | |
1159 |
self._content = content |
|
1159 | self._content = content | |
1160 | return self._content |
|
1160 | return self._content | |
1161 |
|
1161 | |||
1162 | @property |
|
1162 | @property |
@@ -298,7 +298,7 b' class OAuth2(providers.AuthorizationProv' | |||||
298 | # unquote Cast to str to void b64decode translation error. Base64 |
|
298 | # unquote Cast to str to void b64decode translation error. Base64 | |
299 | # should be str compatible. |
|
299 | # should be str compatible. | |
300 | return json.loads(base64.urlsafe_b64decode( |
|
300 | return json.loads(base64.urlsafe_b64decode( | |
301 |
unquote(str(state))) |
|
301 | unquote(str(state))))[param] | |
302 | else: |
|
302 | else: | |
303 | return state if param == 'csrf' else '' |
|
303 | return state if param == 'csrf' else '' | |
304 |
|
304 |
@@ -156,7 +156,7 b' class RhodeCodeSetting(Base, BaseModel):' | |||||
156 |
|
156 | |||
157 | @validates('_app_settings_value') |
|
157 | @validates('_app_settings_value') | |
158 | def validate_settings_value(self, key, val): |
|
158 | def validate_settings_value(self, key, val): | |
159 |
assert type(val) == |
|
159 | assert type(val) == str | |
160 | return val |
|
160 | return val | |
161 |
|
161 | |||
162 | @hybrid_property |
|
162 | @hybrid_property |
@@ -178,7 +178,7 b' class RhodeCodeSetting(Base, BaseModel):' | |||||
178 |
|
178 | |||
179 | @validates('_app_settings_value') |
|
179 | @validates('_app_settings_value') | |
180 | def validate_settings_value(self, key, val): |
|
180 | def validate_settings_value(self, key, val): | |
181 |
assert type(val) == |
|
181 | assert type(val) == str | |
182 | return val |
|
182 | return val | |
183 |
|
183 | |||
184 | @hybrid_property |
|
184 | @hybrid_property |
@@ -57,7 +57,6 b' def rfc2822_date(date):' | |||||
57 | month = months[date.month - 1] |
|
57 | month = months[date.month - 1] | |
58 | time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month)) |
|
58 | time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month)) | |
59 |
|
59 | |||
60 | time_str = time_str.decode('utf-8') |
|
|||
61 | offset = date.utcoffset() |
|
60 | offset = date.utcoffset() | |
62 | # Historically, this function assumes that naive datetimes are in UTC. |
|
61 | # Historically, this function assumes that naive datetimes are in UTC. | |
63 | if offset is None: |
|
62 | if offset is None: | |
@@ -73,7 +72,6 b' def rfc3339_date(date):' | |||||
73 | date = datetime_safe.new_datetime(date) |
|
72 | date = datetime_safe.new_datetime(date) | |
74 | time_str = date.strftime('%Y-%m-%dT%H:%M:%S') |
|
73 | time_str = date.strftime('%Y-%m-%dT%H:%M:%S') | |
75 |
|
74 | |||
76 | time_str = time_str.decode('utf-8') |
|
|||
77 | offset = date.utcoffset() |
|
75 | offset = date.utcoffset() | |
78 | # Historically, this function assumes that naive datetimes are in UTC. |
|
76 | # Historically, this function assumes that naive datetimes are in UTC. | |
79 | if offset is None: |
|
77 | if offset is None: |
@@ -1441,7 +1441,7 b' def gravatar_url(email_address, size=30,' | |||||
1441 | _use_gravatar = request.call_context.visual.use_gravatar |
|
1441 | _use_gravatar = request.call_context.visual.use_gravatar | |
1442 |
|
1442 | |||
1443 | email_address = email_address or User.DEFAULT_USER_EMAIL |
|
1443 | email_address = email_address or User.DEFAULT_USER_EMAIL | |
1444 |
if isinstance(email_address, |
|
1444 | if isinstance(email_address, str): | |
1445 | # hashlib crashes on unicode items |
|
1445 | # hashlib crashes on unicode items | |
1446 | email_address = safe_str(email_address) |
|
1446 | email_address = safe_str(email_address) | |
1447 |
|
1447 |
@@ -79,7 +79,7 b' class HooksHttpHandler(BaseHTTPRequestHa' | |||||
79 | # support for new vcsserver msgpack based protocol hooks |
|
79 | # support for new vcsserver msgpack based protocol hooks | |
80 | data = msgpack.unpackb(self.rfile.read(length), raw=False) |
|
80 | data = msgpack.unpackb(self.rfile.read(length), raw=False) | |
81 | else: |
|
81 | else: | |
82 |
body = self.rfile.read(length) |
|
82 | body = self.rfile.read(length) | |
83 | data = json.loads(body) |
|
83 | data = json.loads(body) | |
84 |
|
84 | |||
85 | return hooks_proto, data['method'], data['extras'] |
|
85 | return hooks_proto, data['method'], data['extras'] |
@@ -285,7 +285,7 b' class InvalidationContext(object):' | |||||
285 | self.uid = uid |
|
285 | self.uid = uid | |
286 | self.invalidation_namespace = invalidation_namespace |
|
286 | self.invalidation_namespace = invalidation_namespace | |
287 | self.raise_exception = raise_exception |
|
287 | self.raise_exception = raise_exception | |
288 |
self.proc_id = |
|
288 | self.proc_id = rhodecode.CONFIG.get('instance_id') or 'DEFAULT' | |
289 | self.thread_id = 'global' |
|
289 | self.thread_id = 'global' | |
290 |
|
290 | |||
291 | if thread_scoped is None: |
|
291 | if thread_scoped is None: |
@@ -240,7 +240,7 b' class GitRepository(BaseRepository):' | |||||
240 | commit_missing_err = "Commit {} does not exist for `{}`".format( |
|
240 | commit_missing_err = "Commit {} does not exist for `{}`".format( | |
241 | *map(safe_str, [commit_id_or_idx, self.name])) |
|
241 | *map(safe_str, [commit_id_or_idx, self.name])) | |
242 |
|
242 | |||
243 |
is_bstr = isinstance(commit_id_or_idx, |
|
243 | is_bstr = isinstance(commit_id_or_idx, str) | |
244 | is_branch = reference_obj and reference_obj.branch |
|
244 | is_branch = reference_obj and reference_obj.branch | |
245 |
|
245 | |||
246 | lookup_ok = False |
|
246 | lookup_ok = False |
@@ -180,7 +180,7 b' def _stub_git_repo(repo_path):' | |||||
180 | repo_path.ensure('.git', dir=True) |
|
180 | repo_path.ensure('.git', dir=True) | |
181 |
|
181 | |||
182 |
|
182 | |||
183 |
@pytest.mark.parametrize('str_class', [str, |
|
183 | @pytest.mark.parametrize('str_class', [str, bytes], ids=['str', 'bytes']) | |
184 | def test_get_dirpaths_returns_all_paths(tmpdir, str_class): |
|
184 | def test_get_dirpaths_returns_all_paths(tmpdir, str_class): | |
185 | tmpdir.ensure('test-file') |
|
185 | tmpdir.ensure('test-file') | |
186 | dirpaths = utils._get_dirpaths(str_class(tmpdir)) |
|
186 | dirpaths = utils._get_dirpaths(str_class(tmpdir)) |
@@ -162,7 +162,7 b' def test_get_nodes_max_file_bytes(backen' | |||||
162 | def assert_contains_only_unicode(structure): |
|
162 | def assert_contains_only_unicode(structure): | |
163 | assert structure |
|
163 | assert structure | |
164 | for value in structure: |
|
164 | for value in structure: | |
165 |
assert isinstance(value, |
|
165 | assert isinstance(value, str) | |
166 |
|
166 | |||
167 |
|
167 | |||
168 | @pytest.mark.backends("hg", "git") |
|
168 | @pytest.mark.backends("hg", "git") |
@@ -69,6 +69,12 b' from rhodecode.config import utils as co' | |||||
69 |
|
69 | |||
70 | log = logging.getLogger(__name__) |
|
70 | log = logging.getLogger(__name__) | |
71 |
|
71 | |||
|
72 | ||||
|
73 | def cmp(a, b): | |||
|
74 | # backport cmp from python2 so we can still use it in the custom code in this module | |||
|
75 | return (a > b) - (a < b) | |||
|
76 | ||||
|
77 | ||||
72 | def _split_comma(value): |
|
78 | def _split_comma(value): | |
73 | return value.split(',') |
|
79 | return value.split(',') | |
74 |
|
80 | |||
@@ -872,7 +878,7 b' def _add_commits_to_repo(vcs_repo, commi' | |||||
872 | commit = None |
|
878 | commit = None | |
873 |
|
879 | |||
874 | for idx, commit in enumerate(commits): |
|
880 | for idx, commit in enumerate(commits): | |
875 |
message = |
|
881 | message = str(commit.get('message', 'Commit %s' % idx)) | |
876 |
|
882 | |||
877 | for node in commit.get('added', []): |
|
883 | for node in commit.get('added', []): | |
878 | imc.add(FileNode(node.path, content=node.content)) |
|
884 | imc.add(FileNode(node.path, content=node.content)) | |
@@ -891,7 +897,7 b' def _add_commits_to_repo(vcs_repo, commi' | |||||
891 |
|
897 | |||
892 | commit = imc.commit( |
|
898 | commit = imc.commit( | |
893 | message=message, |
|
899 | message=message, | |
894 |
author= |
|
900 | author=str(commit.get('author', 'Automatic <automatic@rhodecode.com>')), | |
895 | date=commit.get('date'), |
|
901 | date=commit.get('date'), | |
896 | branch=commit.get('branch'), |
|
902 | branch=commit.get('branch'), | |
897 | parents=parents) |
|
903 | parents=parents) |
@@ -592,5 +592,5 b' class TestCommitsChanges(BackendTestMixi' | |||||
592 |
|
592 | |||
593 | def assert_text_equal(expected, given): |
|
593 | def assert_text_equal(expected, given): | |
594 | assert expected == given |
|
594 | assert expected == given | |
595 |
assert isinstance(expected, |
|
595 | assert isinstance(expected, str) | |
596 |
assert isinstance(given, |
|
596 | assert isinstance(given, str) |
@@ -29,7 +29,7 b' from rhodecode.tests.vcs.conftest import' | |||||
29 | class TestFileNodeUnicodePath(BackendTestMixin): |
|
29 | class TestFileNodeUnicodePath(BackendTestMixin): | |
30 |
|
30 | |||
31 | fname = 'ąśðąęłąć.txt' |
|
31 | fname = 'ąśðąęłąć.txt' | |
32 |
ufname = |
|
32 | ufname = fname | |
33 |
|
33 | |||
34 | @classmethod |
|
34 | @classmethod | |
35 | def _get_commits(cls): |
|
35 | def _get_commits(cls): |
@@ -965,17 +965,17 b' class TestGitCommit(object):' | |||||
965 |
|
965 | |||
966 | def test_commit_message_is_unicode(self): |
|
966 | def test_commit_message_is_unicode(self): | |
967 | for commit in self.repo: |
|
967 | for commit in self.repo: | |
968 |
assert type(commit.message) == |
|
968 | assert type(commit.message) == str | |
969 |
|
969 | |||
970 | def test_commit_author_is_unicode(self): |
|
970 | def test_commit_author_is_unicode(self): | |
971 | for commit in self.repo: |
|
971 | for commit in self.repo: | |
972 |
assert type(commit.author) == |
|
972 | assert type(commit.author) == str | |
973 |
|
973 | |||
974 | def test_repo_files_content_is_unicode(self): |
|
974 | def test_repo_files_content_is_unicode(self): | |
975 | commit = self.repo.get_commit() |
|
975 | commit = self.repo.get_commit() | |
976 | for node in commit.get_node('/'): |
|
976 | for node in commit.get_node('/'): | |
977 | if node.is_file(): |
|
977 | if node.is_file(): | |
978 |
assert type(node.content) == |
|
978 | assert type(node.content) == str | |
979 |
|
979 | |||
980 | def test_wrong_path(self): |
|
980 | def test_wrong_path(self): | |
981 | # There is 'setup.py' in the root dir but not there: |
|
981 | # There is 'setup.py' in the root dir but not there: |
@@ -1084,17 +1084,17 b' class TestMercurialCommit(object):' | |||||
1084 |
|
1084 | |||
1085 | def test_commit_message_is_unicode(self): |
|
1085 | def test_commit_message_is_unicode(self): | |
1086 | for cm in self.repo: |
|
1086 | for cm in self.repo: | |
1087 |
assert type(cm.message) == |
|
1087 | assert type(cm.message) == str | |
1088 |
|
1088 | |||
1089 | def test_commit_author_is_unicode(self): |
|
1089 | def test_commit_author_is_unicode(self): | |
1090 | for cm in self.repo: |
|
1090 | for cm in self.repo: | |
1091 |
assert type(cm.author) == |
|
1091 | assert type(cm.author) == str | |
1092 |
|
1092 | |||
1093 | def test_repo_files_content_is_unicode(self): |
|
1093 | def test_repo_files_content_is_unicode(self): | |
1094 | test_commit = self.repo.get_commit(commit_idx=100) |
|
1094 | test_commit = self.repo.get_commit(commit_idx=100) | |
1095 | for node in test_commit.get_node('/'): |
|
1095 | for node in test_commit.get_node('/'): | |
1096 | if node.is_file(): |
|
1096 | if node.is_file(): | |
1097 |
assert type(node.content) == |
|
1097 | assert type(node.content) == str | |
1098 |
|
1098 | |||
1099 | def test_wrong_path(self): |
|
1099 | def test_wrong_path(self): | |
1100 | # There is 'setup.py' in the root dir but not there: |
|
1100 | # There is 'setup.py' in the root dir but not there: |
@@ -36,9 +36,6 b' class _LazyString(object):' | |||||
36 | translator = req.translate |
|
36 | translator = req.translate | |
37 | return translator(*self.args, **self.kw) |
|
37 | return translator(*self.args, **self.kw) | |
38 |
|
38 | |||
39 | def __unicode__(self): |
|
|||
40 | return unicode(self.eval()) |
|
|||
41 |
|
||||
42 | def __str__(self): |
|
39 | def __str__(self): | |
43 | return self.eval() |
|
40 | return self.eval() | |
44 |
|
41 |
General Comments 0
You need to be logged in to leave comments.
Login now