Mock.patch not reset between django test runs -


i have 2 tests testing view makes call external module. i've mocked mock.patch. i'm calling view using django's test client.

the first test (a test 404 being returned) completes , correct mock called.

when second test runs, runs normal, mock code-under-test has access mock previous test.

you can see in example https://dpaste.de/7zt8 ids in test output incorrect (around line 91).

where getting cached? initial thought import of main module somehow cached between test runs due urlconf stuff. tracing through source code, couldn't find case.

expected: both tests pass.

actual: second test fails due stale mocked import.

if comment out 404 test, other test passes. view registered in url conf string-y version 'repos.views.github_webhook'.

i not understand causes exact behaviour seeing, not why mock seemingly working correctly in first test. according mock docs, should patch in namespace under test, i.e. patch("views.tasks").

http://www.voidspace.org.uk/python/mock/patch.html#where-to-patch


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -