Opened 14 years ago
Closed 14 years ago
#15751 closed Bug (invalid)
test_requestsite_sitemap in SitemapTests is setting Site._meta.installed to False permanently
Reported by: | lucho | Owned by: | nobody |
---|---|---|---|
Component: | contrib.sitemaps | Version: | 1.3 |
Severity: | Normal | Keywords: | test_requestsite_sitemap |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
test_requestsite_sitemap in SitemapTests is setting Site._meta.installed to False permanently - http://code.djangoproject.com/browser/django/trunk/django/contrib/sitemaps/tests/basic.py#L147
This prevents the remaining tests in the suit to be executed correct, when django.contrib.sites is installed app.
The observed result: SitemapTests.test_simple_sitemap failed.
====================================================================== FAIL: test_simple_sitemap (django.contrib.sitemaps.tests.basic.SitemapTests) A simple sitemap can be rendered ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/sitemaps/tests/basic.py", line 70, in test_simple_sitemap """ % (self.base_url, date.today().strftime('%Y-%m-%d'))) AssertionError: '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n<url><loc>http://testserver/location/</loc><lastmod>2011-04-04</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>\n</urlset>\n' != '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n<url><loc>http://example.com/location/</loc><lastmod>2011-04-04</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>\n</urlset>\n'
The problem: setUp determines incorrect the base_url, because Site._meta.installed was set permanently to False in test_requestsite_sitemap and never set back to correct value.
http://code.djangoproject.com/browser/django/trunk/django/contrib/sitemaps/tests/basic.py#L18
def setUp(self): if Site._meta.installed: self.base_url = 'http://example.com' else: self.base_url = 'http://testserver'