unit testing - Python patch decorator spilling into other methods -
My understanding is that when you use a patch decorator on a unit test (I am using the nose frame) So, the scope of the patch decorator test case is the scope. Here's the problem:
@ patch ('a') @ patch ('b') @ patch ('b') def test_add_stuff (auto, head_a, mock_b, mock c): url = '/ Path / blah / blah' assert_true (content) # Now those three patch decorators should be done "def" test_delete_stuff (self): url = '/ another_path / not_important' assert_true (some)
In the case of my second test, test_delete_stuff, I have added a print statement to the actual code which was thrown in an attempt to debug an error. Exits, the function call within a controller action hit through a URL is returning a MagicMock object! This is the mock_b from the last test case.
If I reverse the order of only two test cases, then there is no change if I comment with the patch decorator then my second test passes the case.
Additional information: There is no patch decorator on the class, which are under these example methods.
Any thoughts?
- UPDATE -
It turns out that I did not mock my function call, and fixed the problem. However, it does not explain why the scope of patch was more than the case of an exam.
If the controller is started immediately, then the GET request is sent using the app.zet, and the import file gets imported into the joke, the MagicMock object has several unit tests Continue through?
Comments
Post a Comment