我的组件很简单:
<template>
<btn :color="color" @click="toggleColor">{{btnmsg}}</btn>
</template>
<script>
import { Btn } from 'chico'
export default {
name: 'AButton',
components: {
Btn
},
data() {
return {
btnmsg: 'Legia pany',
colors: [
'blue', 'black', 'green',
'orange', 'teal', 'cyan',
'yellow', 'white'
],
color: 'red'
}
},
methods: {
toggleColor() {
this.color = this.colors[Math.floor(Math.random() * Math.floor(this.colors.length))];
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
ChicoFamily 的内容<Btn>是这样的:
<template>
<button :is="tag" :class="[className, {'active': active}]" :type="type" :role="role">
<slot></slot>
</button>
</template>
<script>
import classNames from 'classnames';
export default { …Run Code Online (Sandbox Code Playgroud) 我有一个简单的路由器,旨在抛出HTTPException:
@router.get('/404test')
async def test():
raise HTTPException(HTTP_404_NOT_FOUND, "404 test!")
Run Code Online (Sandbox Code Playgroud)
我想断言抛出了异常,根据FastaAPI 文档:
def test_test():
response = client.get("/404test")
assert response.status_code == 404
Run Code Online (Sandbox Code Playgroud)
在评估断言之前抛出异常,将测试标记为失败:
> raise HTTPException(HTTP_404_NOT_FOUND, "404 test!")
E fastapi.exceptions.HTTPException: (404, '404 test!')
Run Code Online (Sandbox Code Playgroud)
HTTPExceptions我在测试中缺少什么来正确预测?