Questions about Unittest

What do the parts marked with green lines in Figure 1 and Figure 2 do to the code respectively? Why are their running results different? I am a Python beginner and hope someone can answer this.

(Figure 1 and Figure 2 are two versions of the same code, and Figure 3 is the test for Figure 1 and Figure 2)

Well the first one has a side effect, because it increases salary by 5,000, whereas the second one doesn’t.

For a function called show_salaryit is typically unexpected to have side effects like that.

2 Likes

Please display code (and code output) lines between lines with triple backticks, like

```
class Employee:
# and so on
```

(I used triple tildas ~~~ to quote and display the triple backticks.)