Opened 11 years ago
Closed 10 years ago
#22501 closed Bug (invalid)
The testing client of LiveServerTestCase has the wrong server address
Reported by: | Benny Daon | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When executing a test using self.client
the view's request
has 'testserver' as the SERVER_NAME
and '80' as the SERVER_PORT
regardless of the actual address used by the live server.
Change History (3)
comment:1 by , 11 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 11 years ago
Has patch: | set |
---|---|
Resolution: | invalid |
Status: | closed → new |
Sorry for not being descriptive enough, let me try again.
My app's view is accessing the RESTfull API of my project and is using the request object to find out the local address (I know it's not the right way to do thing, and I'm only doing it because we have two projects that interact and it's still not clear where the app will be). Writing the tests we've discovered that even though we're using the LiveServerTestCase, the view gets the wrong address in the request
object.
comment:3 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Hi,
this is actually a feature, to have reproducible tests wherever you run them: https://github.com/django/django/blob/master/django/test/client.py#L236
The test client is not meant to query the live server. To interact with the live server, use Selenium.