updated imports in tests
This commit is contained in:
@@ -17,12 +17,12 @@ from .test_serializers import *
|
||||
from .test_template import *
|
||||
from .test_validators import *
|
||||
from .test_utils import *
|
||||
from .test_contribs import *
|
||||
from .test_web import *
|
||||
from .test_dal import *
|
||||
from .test_tools import *
|
||||
from .test_appadmin import *
|
||||
from .test_scheduler import *
|
||||
|
||||
if sys.version[:3] == '2.7':
|
||||
from test_old_doctests import *
|
||||
from .test_web import *
|
||||
from .test_contribs import *
|
||||
from .test_old_doctests import *
|
||||
|
||||
@@ -10,15 +10,15 @@ import sys
|
||||
import unittest
|
||||
import json
|
||||
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from compileapp import run_controller_in, run_view_in
|
||||
from languages import translator
|
||||
from gluon.compileapp import run_controller_in, run_view_in
|
||||
from gluon.languages import translator
|
||||
from gluon.storage import Storage, List
|
||||
import gluon.fileutils
|
||||
from gluon import fileutils
|
||||
from gluon.dal import DAL, Field, Table
|
||||
from gluon.http import HTTP
|
||||
|
||||
@@ -36,13 +36,13 @@ class TestAppAdmin(unittest.TestCase):
|
||||
from gluon.globals import Request, Response, Session, current
|
||||
from gluon.html import A, DIV, FORM, MENU, TABLE, TR, INPUT, URL, XML
|
||||
from gluon.validators import IS_NOT_EMPTY
|
||||
from compileapp import LOAD
|
||||
from gluon.compileapp import LOAD
|
||||
from gluon.http import HTTP, redirect
|
||||
from gluon.tools import Auth
|
||||
from gluon.sql import SQLDB
|
||||
from gluon.sqlhtml import SQLTABLE, SQLFORM
|
||||
self.original_check_credentials = gluon.fileutils.check_credentials
|
||||
gluon.fileutils.check_credentials = fake_check_credentials
|
||||
self.original_check_credentials = fileutils.check_credentials
|
||||
fileutils.check_credentials = fake_check_credentials
|
||||
request = Request(env={})
|
||||
request.application = 'welcome'
|
||||
request.controller = 'appadmin'
|
||||
@@ -73,7 +73,7 @@ class TestAppAdmin(unittest.TestCase):
|
||||
self.env = locals()
|
||||
|
||||
def tearDown(self):
|
||||
gluon.fileutils.check_credentials = self.original_check_credentials
|
||||
fileutils.check_credentials = self.original_check_credentials
|
||||
|
||||
def run_function(self):
|
||||
return run_controller_in(self.env['request'].controller, self.env['request'].function, self.env)
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
"""
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from storage import Storage
|
||||
from cache import CacheInRam, CacheOnDisk, Cache
|
||||
from gluon.storage import Storage
|
||||
from gluon.cache import CacheInRam, CacheOnDisk, Cache
|
||||
from gluon.dal import DAL, Field
|
||||
|
||||
oldcwd = None
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
""" Unit tests for utils.py """
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from compileapp import compile_application, remove_compiled_application
|
||||
from gluon.compileapp import compile_application, remove_compiled_application
|
||||
from gluon.fileutils import w2p_pack, w2p_unpack
|
||||
import os
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from contenttype import contenttype
|
||||
|
||||
from gluon.contenttype import contenttype
|
||||
from gluon._compat import iteritems
|
||||
|
||||
class TestContentType(unittest.TestCase):
|
||||
|
||||
@@ -31,7 +31,7 @@ class TestContentType(unittest.TestCase):
|
||||
'.w2p': 'application/w2p',
|
||||
'.md': 'text/x-markdown; charset=utf-8'
|
||||
}
|
||||
for k, v in mapping.iteritems():
|
||||
for k, v in iteritems(mapping):
|
||||
self.assertEqual(contenttype(k), v)
|
||||
|
||||
# test without dot extension
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
import unittest
|
||||
import os
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from gluon.storage import Storage
|
||||
import gluon.contrib.fpdf as fpdf
|
||||
import gluon.contrib.pyfpdf as pyfpdf
|
||||
from gluon.contrib import fpdf as fpdf
|
||||
from gluon.contrib import pyfpdf as pyfpdf
|
||||
from gluon.contrib.appconfig import AppConfig
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from fileutils import parse_version
|
||||
from gluon.fileutils import parse_version
|
||||
|
||||
|
||||
class TestFileUtils(unittest.TestCase):
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import re
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
+13
-10
@@ -6,16 +6,17 @@
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from html import *
|
||||
from html import verifyURL
|
||||
from html import truncate_string
|
||||
from storage import Storage
|
||||
from html import XML_pickle, XML_unpickle
|
||||
from html import TAG_pickler, TAG_unpickler
|
||||
from gluon.html import A, ASSIGNJS, B, BEAUTIFY, P, BODY, BR, BUTTON, CAT, CENTER, CODE, COL, COLGROUP, DIV, SPAN, URL, verifyURL
|
||||
from gluon.html import truncate_string, EM, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IFRAME, IMG, INPUT, EMBED
|
||||
from gluon.html import LABEL, LEGEND, LI, LINK, MARKMIN, MENU, META, OBJECT, OL, OPTGROUP, OPTION, PRE, SCRIPT, SELECT, STRONG
|
||||
from gluon.html import STYLE, TABLE, TR, TD, TAG, TBODY, THEAD, TEXTAREA, TFOOT, TH, TITLE, TT, UL, XHTML, XML
|
||||
from gluon.storage import Storage
|
||||
from gluon.html import XML_pickle, XML_unpickle
|
||||
from gluon.html import TAG_pickler, TAG_unpickler
|
||||
|
||||
|
||||
class TestBareHelpers(unittest.TestCase):
|
||||
@@ -41,7 +42,7 @@ class TestBareHelpers(unittest.TestCase):
|
||||
self.assertEqual(URL('a', 'static', 'design.css'), '/a/static/design.css')
|
||||
response = Storage()
|
||||
response.static_version = '1.2.3'
|
||||
from globals import current
|
||||
from gluon.globals import current
|
||||
current.response = response
|
||||
self.assertEqual(URL('a', 'static', 'design.css'), '/a/static/design.css')
|
||||
response.static_version_urls = True
|
||||
@@ -53,6 +54,8 @@ class TestBareHelpers(unittest.TestCase):
|
||||
self.assertEqual(URL('a', 'c', 'f', args=['1', '2']), '/a/c/f/1/2')
|
||||
self.assertEqual(URL('a', 'c', '/f'), '/a/c/f')
|
||||
self.assertEqual(URL('a', 'c', 'f.json'), '/a/c/f.json')
|
||||
from gluon.globals import current
|
||||
current.request = None
|
||||
self.assertRaises(SyntaxError, URL, *['a'])
|
||||
|
||||
request = Storage()
|
||||
@@ -61,7 +64,7 @@ class TestBareHelpers(unittest.TestCase):
|
||||
request.function = 'f'
|
||||
request.env = {}
|
||||
|
||||
from globals import current # Can't be moved with other import
|
||||
from gluon.globals import current # Can't be moved with other import
|
||||
current.request = request
|
||||
|
||||
must_return = '/a/c/f'
|
||||
@@ -144,7 +147,7 @@ class TestBareHelpers(unittest.TestCase):
|
||||
rtn = verifyURL(r)
|
||||
self.assertEqual(rtn, False)
|
||||
# emulate user signature
|
||||
from globals import current
|
||||
from gluon.globals import current
|
||||
current.session = Storage(auth=Storage(hmac_key='key'))
|
||||
r.get_vars['_signature'] = 'a32530f0d0caa80964bb92aad2bedf8a4486a31f'
|
||||
rtn = verifyURL(r, user_signature=True)
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
"""Unit tests for http.py """
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from http import HTTP, defined_status
|
||||
from gluon.http import HTTP, defined_status
|
||||
|
||||
|
||||
class TestHTTP(unittest.TestCase):
|
||||
|
||||
@@ -5,13 +5,13 @@ Unit tests for IS_URL()
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from validators import IS_URL, IS_HTTP_URL, IS_GENERIC_URL
|
||||
from validators import unicode_to_ascii_authority
|
||||
from gluon.validators import IS_URL, IS_HTTP_URL, IS_GENERIC_URL
|
||||
from gluon.validators import unicode_to_ascii_authority
|
||||
|
||||
|
||||
class TestIsUrl(unittest.TestCase):
|
||||
@@ -296,7 +296,7 @@ class TestIsGenericUrl(unittest.TestCase):
|
||||
|
||||
def testInvalidUrls(self):
|
||||
urlsToCheckA = []
|
||||
for i in range(0, 32) + [127]:
|
||||
for i in list(range(0, 32)) + [127]:
|
||||
|
||||
# Control characters are disallowed in any part of a URL
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from gluon import languages
|
||||
|
||||
import languages
|
||||
MP_WORKING = 0
|
||||
try:
|
||||
import multiprocessing
|
||||
|
||||
@@ -9,7 +9,7 @@ import sys
|
||||
import os
|
||||
import doctest
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import unittest
|
||||
import os
|
||||
import shutil
|
||||
import uuid
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
@@ -1044,6 +1044,9 @@ class TestRouter(unittest.TestCase):
|
||||
'http://domain.com/app2/static/filename-with_underscore'),
|
||||
norm_root("%s/applications/app2/static/filename-with_underscore" % root))
|
||||
|
||||
from gluon.globals import current
|
||||
current.response.static_version = None
|
||||
|
||||
self.assertEqual(str(URL(a='init', c='default', f='a_b')), "/a_b")
|
||||
self.assertEqual(str(URL(a='app1', c='default', f='a_b')), "/app1/a-b")
|
||||
self.assertEqual(str(URL(a='app2', c='default', f='a_b')), "/app2/a_b")
|
||||
|
||||
@@ -65,7 +65,7 @@ def setUpModule():
|
||||
if not os.path.isdir('gluon'):
|
||||
os.chdir(os.path.realpath(
|
||||
'../../')) # run from web2py base directory
|
||||
import main # for initialization after chdir
|
||||
from gluon import main # for initialization after chdir
|
||||
global logger
|
||||
logger = logging.getLogger('web2py.rewrite')
|
||||
global_settings.applications_parent = tempfile.mkdtemp()
|
||||
|
||||
@@ -10,7 +10,7 @@ import glob
|
||||
import datetime
|
||||
import sys
|
||||
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
import datetime
|
||||
import decimal
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from serializers import *
|
||||
from storage import Storage
|
||||
from gluon.serializers import *
|
||||
from gluon.storage import Storage
|
||||
# careful with the import path 'cause of isinstance() checks
|
||||
from gluon.languages import translator
|
||||
from gluon.html import SPAN
|
||||
|
||||
@@ -8,7 +8,7 @@ import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
@@ -18,12 +18,12 @@ DEFAULT_URI = os.getenv('DB', 'sqlite:memory')
|
||||
|
||||
from gluon.dal import DAL, Field
|
||||
from pydal.objects import Table
|
||||
from tools import Auth, Mail
|
||||
from gluon.tools import Auth, Mail
|
||||
from gluon.globals import Request, Response, Session
|
||||
from storage import Storage
|
||||
from languages import translator
|
||||
from gluon.storage import Storage
|
||||
from gluon.languages import translator
|
||||
from gluon.http import HTTP
|
||||
from validators import *
|
||||
from gluon.validators import *
|
||||
|
||||
# TODO: Create these test...
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
""" Unit tests for storage.py """
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from storage import Storage, StorageList, List
|
||||
from http import HTTP
|
||||
import pickle
|
||||
from gluon.storage import Storage, StorageList, List
|
||||
from gluon.http import HTTP
|
||||
from gluon._compat import pickle
|
||||
|
||||
|
||||
class TestStorage(unittest.TestCase):
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
import template
|
||||
from template import render
|
||||
from gluon import template
|
||||
from gluon.template import render
|
||||
|
||||
|
||||
class TestTemplate(unittest.TestCase):
|
||||
|
||||
@@ -10,7 +10,7 @@ import smtplib
|
||||
import datetime
|
||||
import unittest
|
||||
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
@@ -18,13 +18,12 @@ DEFAULT_URI = os.getenv('DB', 'sqlite:memory')
|
||||
|
||||
from gluon.dal import DAL, Field
|
||||
from pydal.objects import Table
|
||||
from tools import Auth, Mail, Recaptcha, Recaptcha2, prettydate
|
||||
from gluon.tools import Auth, Mail, Recaptcha, Recaptcha2, prettydate
|
||||
from gluon.globals import Request, Response, Session
|
||||
from storage import Storage
|
||||
from languages import translator
|
||||
from gluon.storage import Storage
|
||||
from gluon.languages import translator
|
||||
from gluon.http import HTTP
|
||||
|
||||
python_version = sys.version[:3]
|
||||
IS_IMAP = "imap" in DEFAULT_URI
|
||||
|
||||
|
||||
|
||||
@@ -4,18 +4,15 @@
|
||||
""" Unit tests for utils.py """
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from utils import md5_hash
|
||||
from utils import compare
|
||||
from utils import is_valid_ip_address
|
||||
from utils import web2py_uuid
|
||||
from gluon.utils import md5_hash, compare, is_valid_ip_address, web2py_uuid
|
||||
|
||||
import hashlib
|
||||
from hashlib import md5, sha1, sha224, sha256, sha384, sha512
|
||||
from utils import simple_hash, get_digest, secure_dumps, secure_loads
|
||||
from gluon.utils import simple_hash, get_digest, secure_dumps, secure_loads
|
||||
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
|
||||
@@ -7,7 +7,7 @@ import unittest
|
||||
import datetime
|
||||
import decimal
|
||||
import re
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ import subprocess
|
||||
import time
|
||||
import signal
|
||||
|
||||
from fix_path import fix_sys_path
|
||||
from .fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from contrib.webclient import WebClient
|
||||
from urllib2 import HTTPError
|
||||
from gluon.contrib.webclient import WebClient
|
||||
from gluon._compat import urllib2
|
||||
|
||||
webserverprocess = None
|
||||
|
||||
@@ -135,7 +135,7 @@ class TestWeb(LiveTest):
|
||||
s = WebClient('http://127.0.0.1:8000/')
|
||||
try:
|
||||
s.post('examples/soap_examples/call/soap', data=xml_request, method="POST")
|
||||
except HTTPError as e:
|
||||
except urllib2.HTTPError as e:
|
||||
assert(e.msg == 'INTERNAL SERVER ERROR')
|
||||
# check internal server error returned (issue 153)
|
||||
assert(s.status == 500)
|
||||
|
||||
Reference in New Issue
Block a user