Skip to content
Advertisement

Test (unittest, mock) if a global variable list is updated

file.py:

JavaScript

test.py:

JavaScript

I always get an AssertionError. from the line assert x in GLOB_VAR

Let me say that I DO need a global variable

Advertisement

Answer

It turned out that I shouldn’t have patched the global variable as I need to assert against the file’s global variable and not against the a mock’s instance global variable.

This does does the trick:

test.py

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement