I try to setup my Django tests, and I noticed that when I run all tests TestRunner uses correct test database (for all aliases): docker-compose exec my_project python manage.py test –keepdb But when I run tests for specific module, it uses the original database: docker-compose exec my_project python manage.py test –keepdb apps.my_module What is the reason of such behavior? Using
Tag: django-testing
TypeError: test_admin_login() missing 1 required positional argument: ‘self’
I’m writing test cases for my Django-based rest APIs. The problem is in the method of testcase class. I want to use test_admin_login method in the setuptestdata method. And I’m unable to do that. I’m getting error that I mentioned in the title. Answer if any function needs the self this means you need to create an instance of it
Django test with fixtures gives ForeignKeyViolation or IntegrityError
I am trying to write test cases for the Django RestAPI that we have but I have an issue with the fixtures loading. Everything works correctly when I have only one TestCase but when I add a second TestCase in a second django app I get django.db.utils.IntegrityError. My original intention was to create a general TestCase where I set up
How to test successful token claim with jwt
I’m using django rest simple jwt and I wanted to test a simple login and check the response data for the token and other custom data. So I tried with the APITestCase to create an user and then try a login with the same credentials. The results is a 401 instead a 200 with a token in response data. Here
What are the differences between setUpClass, setUpTestData and setUp in TestCase class?
More specifically, what are the use cases for each? What I’ve understood so far: setUpClass This method runs once, before all the tests in a test class setUpTestData This method runs once if the DB has transaction support. Otherwise it runs before each test. setUp This method runs before each test in a test class. From the understanding I mentioned
how do I efficiently test this Django model?
I’m building an authentication system for a website, I don’t have prior test experience with Django. I have written some basic tests. the model, and model manager, and my tests, fortunately all the passes, and my question is, are these tests overdone or underdone or normal? What should be tested in a model? is there any procedure missing? anything wrong