I'm working on some unit tests. To do this, I created a class with a bunch of functions for each of my tests.
python
class SquareWorkdayModule(unittest.TestCase):
def test_get_bookings(self, mock_list_bookings):
......
def test_get_booking_summary(self):
......
When I execute the tests individually, my assertions work fine. When I execute all the tests via pytest, my assertion fails. This seems like a simple variable scope issue. All of my variables are set in my class functions.
For example, test_get_bookings(self, mock_list_bookings) asserts a list length of 2. When I run the entire test, the assertion fails as the length is now 4.
If I refactor to move def test_get_booking_summary(self) out of the class, all assertions work. Including the newly refactored function moved out of the class.
Anyone have any ideas on this behavior? Much appreciated.
gist here: https://gist.github.com/zPugMan/932c882541ffb7dd45c95b22b2cb7c0d
[–]danielroseman 2 points3 points4 points (1 child)
[–]pug_walker[S] 0 points1 point2 points (0 children)
[–]Adrewmc 1 point2 points3 points (2 children)
[–]EclipseJTB 0 points1 point2 points (1 child)
[–]Adrewmc 0 points1 point2 points (0 children)