小编Jak*_*yko的帖子

如何在 Vue 2 中的 props 更改后重新渲染组件?

我的组件很简单:

<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)

vue.js vue-component vuejs2 vue-props

13
推荐指数
2
解决办法
2万
查看次数

如何在 FastAPI Pytest 中断言预期的 HTTPException?

我有一个简单的路由器,旨在抛出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我在测试中缺少什么来正确预测?

python pytest fastapi

6
推荐指数
2
解决办法
3927
查看次数

标签 统计

fastapi ×1

pytest ×1

python ×1

vue-component ×1

vue-props ×1

vue.js ×1

vuejs2 ×1