Commit e9e4fd8d authored by Mikaël Salson's avatar Mikaël Salson

Merge branch 'feature-s/print-server-tests' into 'dev'

Convert server unit tests to Python 3's print

See merge request !111
parents df1fd249 207cce64
#!/usr/bin/python
from __future__ import print_function
import unittest
from gluon.globals import Request, Session, Storage, Response
from gluon.contrib.test_helpers import form_postvars
......@@ -99,7 +101,7 @@ class ConfigController(unittest.TestCase):
request.vars["id"] = id_config
resp = delete()
print resp
print(resp)
self.assertEqual(resp.find('config deleted'), -1, "delete doesn't return a valid message")
......
#!/usr/bin/python
from __future__ import print_function
import unittest
import tempfile
import gluon.contrib.simplejson
......@@ -78,7 +80,7 @@ class DefaultController(unittest.TestCase):
def testCustomDataNoFile(self):
resp = gluon.contrib.simplejson.loads(get_custom_data())
print resp['message']
print(resp['message'])
self.assertTrue(resp.has_key('success'))
self.assertEqual(resp['success'], 'false')
self.assertNotEqual(resp['message'].find('get_custom_data'), -1)
......@@ -95,7 +97,7 @@ class DefaultController(unittest.TestCase):
def testCustomData(self):
request.vars['custom'] = [str(fake_result_id2), str(fake_result_id2)]
resp = gluon.contrib.simplejson.loads(get_custom_data())
print resp
print(resp)
if resp.has_key('success') and resp['success'] == 'false':
self.assertTrue(defs.PORT_FUSE_SERVER is None, 'get_custom_data returns error without fuse server')
else:
......
#!/usr/bin/python
from __future__ import print_function
import unittest
from mock import MagicMock, Mock, patch
from gluon.globals import Request, Session, Storage, Response
......@@ -202,7 +204,7 @@ class FileController(unittest.TestCase):
sequence_id = self.createDumbSequenceFile()
request.vars['sequence_file_id'] = sequence_id
res = restart_pre_process()
print res
print(res)
self.assertNotEqual(res.find('message'), -1, 'missing message in response')
def testRestartPreProcessInexistantFile(self):
......@@ -211,5 +213,5 @@ class FileController(unittest.TestCase):
with patch.object(Scheduler, 'queue_task', return_value=fake_task) as mock_queue_task:
request.vars['sequence_file_id'] = 666
res = restart_pre_process()
print res
print(res)
self.assertNotEqual(res.find('"success":"false"'), -1, 'missing message in response')
......@@ -34,6 +34,8 @@ ndegroot0@gmail.com
from __future__ import print_function
from gluon import current
import gluon
from gluon.tools import Auth
......@@ -274,10 +276,10 @@ suite = unittest.TestSuite()
def showfeedback():
exc_type, exc_value, exc_traceback = sys.exc_info()
print '-'*60
print('-'*60)
for line in traceback.format_exception(exc_type, exc_value,exc_traceback):
print line[:-1]
print '-'*60
print(line[:-1])
print('-'*60)
def custom_execfile(test_file):
......@@ -302,7 +304,7 @@ appname = 'vidjil'
# find doctests in controller
path=os.path.join('applications',appname,'controllers','*.py')
doc_test_files = glob.glob(path)
print len(doc_test_files)," controller files with possible doctests found."
print(len(doc_test_files)," controller files with possible doctests found.")
# get all files with tests
test_files = glob.glob('applications/'+appname+'/tests/*/*.py')
......@@ -311,7 +313,7 @@ if not len(test_files):
raise Exception("No files found for app: " + sys.argv[2])
# Bring in all doc tests and submit them
print "Run doctests" if doc_test_files else "No doctests"
print("Run doctests" if doc_test_files else "No doctests")
for f in doc_test_files:
g=custom_execfile(f)
suite.addTest(doctest.DocFileSuite(f, globs=g,
......
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