9👍
✅
The default domain name for Django’s test client is testserver
. It’s hardcoded in the RequestFactory
base class.
If you want to change the domain for the specific request, you can just pass it as the kwarg:
self.client.get('/some-path', SERVER_NAME="anotherdomain.com")
0👍
I just tried https://docs.djangoproject.com/en/1.9/topics/testing/tools/#liveservertestcase
The default test URL will be http://localhost:8082 and we can request to the same while running tests. And its working for me.
- [Django]-Django/Python convert PDF using shell (os.system/Popen) not working in production
- [Django]-Which software for intranet CMS – Django or Joomla?
- [Django]-Django – how to restrict DeleteView to object owner
0👍
is this the (pytest) answer you are looking for?
@pytest.fixture()
def client() -> "django.test.client.Client":
"""like the default pytest client with a new domain name."""
skip_if_no_django()
return Client(SERVER_NAME = 'my-server.com')
- [Django]-Django EmailMultiAlternatives sending to multiple "to" addresses
- [Django]-ManagementForm data missing error while formset validation
- [Django]-File does not exist: /var/www/polls
Source:stackexchange.com