Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Testing a function in python without in- and output value

$
0
0

I have the following function in my py-file.

def change_grid():    print("switch grid, current value:", grid_var.get())    global grid    if grid_var.get() == "off":        grid = False    else:        grid = True

How can I test this function with unittest, as it has no return value?

I searched and found that I can mock the grid_var.get() function so it returns "off" in the test. But how can I check if the global variable grid is set to false or true in the test?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>