Jackson Tale
Jackson Tale

Reputation: 25842

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.

How to write a unit test to test the order of the executions inside process?


I am not asking the execution order of tests, not like these questions

Python unittest.TestCase execution order

Execution order on python unittest

Upvotes: 0

Views: 256

Answers (1)

Daniel
Daniel

Reputation: 42778

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.

Upvotes: 3

Related Questions