Changeset 6cec675 in mod_gnutls
- Timestamp:
- Oct 8, 2020, 3:58:40 PM (6 months ago)
- Branches:
- asyncio
- Children:
- 90d750d, b0f93c4
- Parents:
- 60a415a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/mgstest/tests.py
r60a415a r6cec675 253 253 """ 254 254 >>> r1 = TestRequest(path='/test.txt', 255 ... expect={ 256 ... 'X-Required-Header': 'Hi!'}})255 ... expect={'headers': {'X-Forbidden-Header': None, 256 ... 'X-Required-Header': 'Hi!'}}) 257 257 >>> r1.check_headers({ 'X-Required-Header': 'Hi!' }) 258 258 >>> r1.check_headers({ 'X-Required-Header': 'Hello!' }) 259 259 Traceback (most recent call last): 260 260 ... 261 mgstest.TestExpectationFailed: Unexpected value in header X-Required-Header: 'Hello!', expected 'Hi!' 261 mgstest.TestExpectationFailed: Unexpected value in header \ 262 X-Required-Header: 'Hello!', expected 'Hi!' 262 263 >>> r1.check_headers({ 'X-Forbidden-Header': 'Hi!' }) 263 264 Traceback (most recent call last): 264 265 ... 265 mgstest.TestExpectationFailed: Unexpected value in header X-Forbidden-Header: 'Hi!', expected None 266 mgstest.TestExpectationFailed: Unexpected value in header \ 267 X-Forbidden-Header: 'Hi!', expected None 266 268 """ 267 269 for name, expected in self.expect['headers'].items(): … … 275 277 def check_body(self, body): 276 278 """ 277 >>> r1 = TestRequest(path='/test.txt', method='GET', headers={}, expect={'status': 200, 'body': {'exactly': 'test\\n'}}) 279 >>> r1 = TestRequest(path='/test.txt', method='GET', headers={}, \ 280 expect={'status': 200, 'body': {'exactly': 'test\\n'}}) 278 281 >>> r1.check_body('test\\n') 279 282 >>> r1.check_body('xyz\\n') … … 281 284 ... 282 285 mgstest.TestExpectationFailed: Unexpected body: 'xyz\\n' != 'test\\n' 283 >>> r2 = TestRequest(path='/test.txt', method='GET', headers={}, expect={'status': 200, 'body': {'contains': ['tes', 'est']}}) 286 >>> r2 = TestRequest(path='/test.txt', method='GET', headers={}, \ 287 expect={'status': 200, 'body': {'contains': ['tes', 'est']}}) 284 288 >>> r2.check_body('test\\n') 285 289 >>> r2.check_body('est\\n') 286 290 Traceback (most recent call last): 287 291 ... 288 mgstest.TestExpectationFailed: Unexpected body: 'est\\n' does not contain 'tes' 289 >>> r3 = TestRequest(path='/test.txt', method='GET', headers={}, expect={'status': 200, 'body': {'contains': 'test'}}) 292 mgstest.TestExpectationFailed: Unexpected body: 'est\\n' \ 293 does not contain 'tes' 294 >>> r3 = TestRequest(path='/test.txt', method='GET', headers={}, \ 295 expect={'status': 200, 'body': {'contains': 'test'}}) 290 296 >>> r3.check_body('test\\n') 291 297 """ … … 300 306 self.expect['body']['contains']] 301 307 for s in self.expect['body']['contains']: 302 if not sin body:308 if s not in body: 303 309 raise TestExpectationFailed( 304 310 f'Unexpected body: {body!r} does not contain ' … … 323 329 connection failed. 324 330 325 >>> r1 = TestRequest(path='/test.txt', method='GET', headers={}, expect={'status': 200, 'body': {'contains': 'test'}}) 331 >>> r1 = TestRequest(path='/test.txt', method='GET', headers={}, \ 332 expect={'status': 200, 'body': {'contains': 'test'}}) 326 333 >>> r1.expects_conn_reset() 327 334 False 328 >>> r2 = TestRequest(path='/test.txt', method='GET', headers={}, expect={'reset': True}) 335 >>> r2 = TestRequest(path='/test.txt', method='GET', headers={}, \ 336 expect={'reset': True}) 329 337 >>> r2.expects_conn_reset() 330 338 True … … 444 452 445 453 def run(self, conn, command): 446 if not '--inline-commands'in command:454 if '--inline-commands' not in command: 447 455 raise ValueError('gnutls_params must include "inline-commands" ' 448 456 'to use the resume action!')
Note: See TracChangeset
for help on using the changeset viewer.