我想测试托管在不同机器上的烧瓶应用程序(例如 - 登台机器以验证是否所有 api 单元测试都通过了),我可以覆盖烧瓶测试客户端中的烧瓶基础 url 吗?
目前所有测试都在 DEV 本地机器上运行。
class TestAPI(unittest.TestCase):
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
create_fake_data(db)
self.client = self.app.test_client()
def tearDown(self):
....
def test_post_panel_with_good_data(self):
# data
r = self.client.post('/customer',
data=json.dumps(data),
follow_redirects=True)
print(r.data)
self.assertEqual(r.status_code, 200)
这里烧瓶测试客户端self.client.post('/customer' ... )
使用本地机器生成最终 URL,但我想传递自定义基本 url,以便最终 url 看起来像这样http://192.168.12.8/customer
。
r = self.client.post('/customer',
data=json.dumps(data),
follow_redirects=True)
请建议一种使用自定义基本 url 运行测试的方法。