简体   繁体   English

如何在python中测试几个函数的执行顺序?

[英]How to test the execution order of several functions in python?

I have several update functions. 我有几个更新功能。 They must be executed in strict order. 必须严格执行它们。

For example 例如

def update1(a1):
  do_something...

def update2(a1, a2):
  do_something...

def update3(a1):
  do_something...


def process(a,b):
  update1(a)
  update2(a,b)
  update3(a)

In process , all update functions must be executed in that order. process ,所有update功能必须按该顺序执行。

How to write a unit test to test the order of the executions inside process ? 如何编写一个单元测试来测试process内部执行的顺序?


I am not asking the execution order of tests , not like these questions 我不是问测试的执行顺序也不喜欢这些问题

Python unittest.TestCase execution order Python unittest.TestCase执行顺序

Execution order on python unittest python unittest的执行顺序

Ask yourself the question, "why is the order important?" 问自己一个问题,“为什么订单很重要?” If you can't tell from outside the difference of calls, you don't have to test them. 如果您无法从外部分辨出通话的区别,则不必测试它们。 If these are for example database updates you have to write a database mockup which logs the order of updates, or make a select statement, that can check, if the updates ocured in the correct order. 例如,如果这些是数据库更新,则必须编写一个数据库模型来记录更新的顺序,或者制作一条select语句,以检查更新是否按照正确的顺序发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM