For some of my Django views I\'ve created a decorator that performs Basic HTTP access authentication. However, while writing test cases in Django, it took me a while to wor
Another way to do it is to bypass the Django Client() and use Requests instead.
class MyTest(TestCase): def setUp(self): AUTH = requests.auth.HTTPBasicAuth("username", "password") def some_test(self): resp = requests.get(BASE_URL + 'endpoint/', auth=AUTH) self.assertEqual(resp.status_code, 200)