I have some code that calls a third-party API in a Django application I'm working on, which could be triggered at various points throughout a project. I would like to ensure that the API itself doesn't actually get called at all during test mode, much the same way that Django itself swaps out the email backend during test mode to ensure emails don't actually get sent during testing.
The key point here is I need to ensure the real library isn't being called anywhere during the tests being run throughout the suite, not just in the test code I'm writing specifically for the application itself. Is there a clean way to do this? I notice that Django disables the email and a few other settings in the setup_test_environment() function. I'd like to do something similar, but the only idea I've come up with so far is to create a custom test runner that extends the default setup_test_environment() method and adds a few items of my own. While this would work, it would depend on the project using a custom test runner. Other ideas include a crazy hack like this guy has proposed: http://www.thebitguru.com/blog/view/246-Using%20custom%20settings%20in%20django%20tests Surely others of you have had to ensure a given library isn't called during testing or development (e.g. if you were implementing a payment processor API, you wouldn't want to actually call that library during tests). Am I just missing a totally obvious way to accomplish this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.