Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7132a99

Browse files
committed
Acceptance Test Improvements
- Make the tests properly catch errors- Report whether there were actual failures instead of silently passing
1 parentc3c69ad commit7132a99

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

‎libs/network/test/httplib_acceptance.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,32 @@
2828
expected=b'Hello, World!'
2929

3030
deftest(url,method,expected,headers={},body=''):
31-
resp,content=client.request(url,method,headers=headers,body=body)
32-
print('Request: {method} {url} body=\'{body}\''.format(method=method,url=url,body=body)),
33-
ifcontent!=expected:
34-
print('ERROR:\'{0}\' !=\'{1}\''.format(content,expected))
31+
globalstatus
32+
try:
33+
print('Request: {method} {url} body=\'{body}\''.format(method=method,url=url,body=body)),
34+
resp,content=client.request(url,method,headers=headers,body=body)
35+
ifcontent!=expected:
36+
print('ERROR:\'{0}\' !=\'{1}\''.format(content,expected))
37+
status=1
38+
else:
39+
print('... passed.')
40+
exceptExceptionase:
41+
print('Caught Exception: {0}'.format(e))
3542
status=1
36-
else:
37-
print('... passed.')
3843

3944
deftest_status(url,method,expected,headers={},body=''):
40-
resp,content=client.request('http://localhost:8000/','PUT',body='')
41-
print('Request: {method} {url} body=\'{body}\''.format(method=method,url=url,body=body)),
42-
ifresp['status']!=expected:
43-
print('ERROR: response status ({0}) != 400'.format(resp['status']))
45+
globalstatus
46+
try:
47+
print('Request: {method} {url} body=\'{body}\''.format(method=method,url=url,body=body)),
48+
resp,content=client.request('http://localhost:8000/','PUT',body='')
49+
ifresp['status']!=expected:
50+
print('ERROR: response status ({0}) != 400'.format(resp['status']))
51+
status=1
52+
else:
53+
print('... passed.')
54+
exceptExceptionase:
55+
print('Caught Exception: {0}'.format(e))
4456
status=1
45-
else:
46-
print('... passed.')
4757

4858
url='http://localhost:8000/'
4959
test(url,'GET',expected)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp