Giter Site home page Giter Site logo

Comments (2)

yanyongyu avatar yanyongyu commented on September 16, 2024 2
  1. 字符串与Message的比较

测试是严谨的断言,不仅是内容比较,也是类型比较。string类型明显于预期Message类型不符,属于测试不通过。
例如 onebot 协议中,matcher.send("[CQ:foo]")matcher.send(Message("[CQ:foo]")) 是两种完全不同的意义

  1. 自定义消息判断

测试中的随机事件尽量用 monkeypatch 替换掉,详情可以参考 pytest 文档,正则的话可能以后会考虑

from nonebug.

ExerciseBook avatar ExerciseBook commented on September 16, 2024 1

2 我感觉可以简单回复一下。

如果有这种需求,可以考虑自己写一下。

因为单元测试本身就是要求完全一致。

你可以这样操作。这个测试期望返回值是 True

然后你的代码里就这样写

actual_result = 你的功能()
if 你觉得对(actual_result) :
    return True
else :
    return False

from nonebug.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.