[tests] add a __main__ handler
the relative import in test_rest_api.py needs to be modified to prevent a
ValueError: Attempted relative import in non-package
--- a/pyramid_cubicweb/tests/test_bw_request.py Tue Mar 22 13:58:38 2016 +0100
+++ b/pyramid_cubicweb/tests/test_bw_request.py Tue Mar 22 14:01:44 2016 +0100
@@ -1,4 +1,4 @@
-# -*- coding: utf8 -*-
+# -*- coding: utf-8 -*-
from StringIO import StringIO
import webtest
@@ -96,3 +96,8 @@
'/', POST=params,
content_type='application/x-www-form-urlencoded'))
self.assertEqual(u"é", req.form['arg'])
+
+
+if __name__ == '__main__':
+ from unittest import main
+ main()
--- a/pyramid_cubicweb/tests/test_core.py Tue Mar 22 13:58:38 2016 +0100
+++ b/pyramid_cubicweb/tests/test_core.py Tue Mar 22 14:01:44 2016 +0100
@@ -42,3 +42,8 @@
res = self.webapp.get('/uncommitable')
self.assertEqual(res.text, 'OK')
self.assertEqual(res.status_int, 200)
+
+
+if __name__ == '__main__':
+ from unittest import main
+ main()
--- a/pyramid_cubicweb/tests/test_login.py Tue Mar 22 13:58:38 2016 +0100
+++ b/pyramid_cubicweb/tests/test_login.py Tue Mar 22 14:01:44 2016 +0100
@@ -39,3 +39,8 @@
self.assertNotIn('auth_tkt', cookies)
self.assertIn('pauth_tkt', cookies)
self.assertIsNotNone(cookies['pauth_tkt'].expires)
+
+
+if __name__ == '__main__':
+ from unittest import main
+ main()
--- a/pyramid_cubicweb/tests/test_rest_api.py Tue Mar 22 13:58:38 2016 +0100
+++ b/pyramid_cubicweb/tests/test_rest_api.py Tue Mar 22 14:01:44 2016 +0100
@@ -1,11 +1,11 @@
from __future__ import absolute_import
-from . import PyramidCWTest
-
from pyramid_cubicweb.rest_api import EntityResource
from pyramid_cubicweb.core import CubicWebPyramidRequest
from pyramid.view import view_config
+from pyramid_cubicweb.tests import PyramidCWTest
+
class RestApiTest(PyramidCWTest):
def includeme(self, config):
@@ -52,3 +52,8 @@
def includeme(config):
config.scan(__name__)
+
+
+if __name__ == '__main__':
+ from unittest import main
+ main()
--- a/pyramid_cubicweb/tests/test_tools.py Tue Mar 22 13:58:38 2016 +0100
+++ b/pyramid_cubicweb/tests/test_tools.py Tue Mar 22 14:01:44 2016 +0100
@@ -24,3 +24,8 @@
with self.admin_access.repo_cnx() as cnx:
tools.cnx_attach_entity(cnx, user)
self.assertEqual(user.login, 'anon')
+
+
+if __name__ == '__main__':
+ from unittest import main
+ main()