Contrib.Sites doctest assumes existence of current site
|Reported by:||evan_schulz||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
django.contrib.sites.tests contains the following test checking that the get_current method throws an exception if the current record doesn't exist:
>>> s = Site.objects.get_current() ... >>> s.delete() >>> Site.objects.get_current() Traceback (most recent call last): ... DoesNotExist: Site matching query does not exist. """
The problem is that the default Site record (added when the table is created) is deleted by this doctest. This creates an inconsistency when running "./manage.py test" as any test cases run before the contrib.sites test case will have a valid current_site() while those that run after won't. This can be even more confusing for someone creating test cases as running tests for an individual app ("./manage.py test myapp") may work fine while running test cases for all apps could fail (once this sites doctest gets thrown into the mix).
Proposal: Restore the default Site record at the end of the sites doctest so that other test cases can assume the record will be there (as the sites, auth, and possibly other contrib tests already do).
Change History (4)
comment:1 Changed 7 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Resolution set to wontfix
- Status changed from new to closed
Changed 7 years ago by evan_schulz
comment:2 Changed 7 years ago by evan_schulz
- Has patch set
- Resolution wontfix deleted
- Status changed from closed to reopened
- Summary changed from Contrib.Sites doctest deletes current site to Contrib.Sites doctest assumes existence of current site