Opened 11 years ago

Closed 11 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 Claude Paroz, 11 years ago

Resolution: invalid
Status: newclosed

The test client is not meant to query the live server. To interact with the live server, use Selenium.

comment:2 by Benny Daon, 11 years ago

Has patch: set
Resolution: invalid
Status: closednew

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.

https://github.com/daonb/django/tree/ticket_22501

comment:3 by Mathieu Agopian, 11 years ago

Resolution: invalid
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top