TA的每日心情 | 无聊 10 小时前 |
---|
签到天数: 528 天 连续签到: 1 天 [LV.9]测试副司令
|
1测试积点
- import atexit
- import unittest
- from pact import Consumer, Provider
- pact = Consumer('Consumer').has_pact_with(Provider('Provider'))
- pact.start_service()
- atexit.register(pact.stop_service)
- class GetUserInfoContract(unittest.TestCase):
- def test_get_user(self):
- expected = {
- 'username': 'UserA',
- 'id': 123,
- 'groups': ['Editors']
- }
- (pact
- .given('UserA exists and is not an administrator')
- .upon_receiving('a request for UserA')
- .with_request('get', '/users/UserA')
- .will_respond_with(200, body=expected))
- with pact:
- result = user('UserA')
- self.assertEqual(result, expected)
- (pact
- .given('UserA exists and is not an administrator')
- .upon_receiving('a request for UserA')
- .with_request('get', '/users/UserA')
- .will_respond_with(200, body=expected))
复制代码 上面那一段是什么个用法,请教一下
|
|