Merge pull request #1225 from BuhtigithuB/pep8-test-web
Improve test_web.py PEP8
This commit is contained in:
+11
-8
@@ -22,20 +22,21 @@ from urllib2 import HTTPError
|
|||||||
|
|
||||||
webserverprocess = None
|
webserverprocess = None
|
||||||
|
|
||||||
|
|
||||||
def startwebserver():
|
def startwebserver():
|
||||||
global webserverprocess
|
global webserverprocess
|
||||||
path = path = os.path.dirname(os.path.abspath(__file__))
|
path = path = os.path.dirname(os.path.abspath(__file__))
|
||||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
if not os.path.isfile(os.path.join(path, 'web2py.py')):
|
||||||
i = 0
|
i = 0
|
||||||
while i<10:
|
while i < 10:
|
||||||
i += 1
|
i += 1
|
||||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
if os.path.exists(os.path.join(path, 'web2py.py')):
|
||||||
break
|
break
|
||||||
path = os.path.abspath(os.path.join(path, '..'))
|
path = os.path.abspath(os.path.join(path, '..'))
|
||||||
web2py_exec = os.path.join(path, 'web2py.py')
|
web2py_exec = os.path.join(path, 'web2py.py')
|
||||||
webserverprocess = subprocess.Popen([sys.executable, web2py_exec, '-a', 'testpass'])
|
webserverprocess = subprocess.Popen([sys.executable, web2py_exec, '-a', 'testpass'])
|
||||||
print 'Sleeping before web2py starts...'
|
print 'Sleeping before web2py starts...'
|
||||||
for a in range(1,11):
|
for a in range(1, 11):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print a, '...'
|
print a, '...'
|
||||||
try:
|
try:
|
||||||
@@ -46,10 +47,11 @@ def startwebserver():
|
|||||||
continue
|
continue
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
|
|
||||||
def terminate_process(pid):
|
def terminate_process(pid):
|
||||||
#Taken from http://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kill-a-subprocess
|
# Taken from http://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kill-a-subprocess
|
||||||
# all this **blah** is because we are stuck with Python 2.5 and \
|
# all this **blah** is because we are stuck with Python 2.5 and \
|
||||||
#we cannot use Popen.terminate()
|
# we cannot use Popen.terminate()
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
import ctypes
|
import ctypes
|
||||||
PROCESS_TERMINATE = 1
|
PROCESS_TERMINATE = 1
|
||||||
@@ -59,10 +61,11 @@ def terminate_process(pid):
|
|||||||
else:
|
else:
|
||||||
os.kill(pid, signal.SIGKILL)
|
os.kill(pid, signal.SIGKILL)
|
||||||
|
|
||||||
|
|
||||||
def stopwebserver():
|
def stopwebserver():
|
||||||
global webserverprocess
|
global webserverprocess
|
||||||
print 'Killing webserver'
|
print 'Killing webserver'
|
||||||
if sys.version_info < (2,6):
|
if sys.version_info < (2, 6):
|
||||||
terminate_process(webserverprocess.pid)
|
terminate_process(webserverprocess.pid)
|
||||||
else:
|
else:
|
||||||
webserverprocess.terminate()
|
webserverprocess.terminate()
|
||||||
@@ -153,7 +156,7 @@ class TestWeb(LiveTest):
|
|||||||
try:
|
try:
|
||||||
s.post('examples/soap_examples/call/soap', data=xml_request, method="POST")
|
s.post('examples/soap_examples/call/soap', data=xml_request, method="POST")
|
||||||
except HTTPError, e:
|
except HTTPError, e:
|
||||||
assert(e.msg=='INTERNAL SERVER ERROR')
|
assert(e.msg == 'INTERNAL SERVER ERROR')
|
||||||
# check internal server error returned (issue 153)
|
# check internal server error returned (issue 153)
|
||||||
assert(s.status == 500)
|
assert(s.status == 500)
|
||||||
assert(s.text == xml_response)
|
assert(s.text == xml_response)
|
||||||
|
|||||||
Reference in New Issue
Block a user