changeset 8046:c6f5c3e60329

tests: fix test_files.py json comparison to load json to struct so it is independent of serialization order Py3 would fail the test because different ordering.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 26 Dec 2019 04:53:38 +0100
parents 05e28260b812
children db6573f71b89
files kallithea/tests/functional/test_files.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/functional/test_files.py	Thu Dec 26 04:55:00 2019 +0100
+++ b/kallithea/tests/functional/test_files.py	Thu Dec 26 04:53:38 2019 +0100
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+import json
 import mimetypes
 import posixpath
 
@@ -119,7 +120,7 @@
                                     revision='tip',
                                     f_path='vcs/nodes.py'),
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'},)
-        assert response.body == HG_NODE_HISTORY
+        assert json.loads(response.body) == json.loads(HG_NODE_HISTORY)
 
     def test_file_source_history_git(self):
         self.log_user()
@@ -128,7 +129,7 @@
                                     revision='master',
                                     f_path='vcs/nodes.py'),
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'},)
-        assert response.body == GIT_NODE_HISTORY
+        assert json.loads(response.body) == json.loads(GIT_NODE_HISTORY)
 
     def test_file_annotation(self):
         self.log_user()
@@ -158,7 +159,7 @@
                                     annotate='1'),
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
 
-        assert response.body == HG_NODE_HISTORY
+        assert json.loads(response.body) == json.loads(HG_NODE_HISTORY)
 
     def test_file_annotation_history_git(self):
         self.log_user()
@@ -169,7 +170,7 @@
                                     annotate=True),
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
 
-        assert response.body == GIT_NODE_HISTORY
+        assert json.loads(response.body) == json.loads(GIT_NODE_HISTORY)
 
     def test_file_authors(self):
         self.log_user()
@@ -210,7 +211,7 @@
                 ('Content-Disposition', 'attachment; filename=%s' % filename),
                 ('Content-Type', info[0]),
             ]
-            assert response.response._headers.items() == heads
+            assert sorted(response.response._headers.items()) == sorted(heads)
 
     def test_archival_wrong_ext(self):
         self.log_user()