# Which does that - setting the Site app as not installed and requesting the url
Site._meta.installed = False
response = self.client.get('/simple/sitemap.xml')

If I execute the test case separate (./manage.py test sitemaps.SitemapTests.test_simple_sitemap) no error is observed, but executing the whole test suite leads to error in test_simple_sitemap which is executed right after the test_requestsite_sitemap.

If I comment out the test_requestsite_sitemap, no problem is observed.
If I don't use (comment out) FetchFromCacheMiddleware, no problem is observed.

The problem is that in those tests, there are several requests for the same URL ('/simple/sitemap.xml', '/simple/sitemap-simple.xml'), so that's totally previsible that when caching is enabled, some already rendered contents are reused. The patch from lucho is one way to solve this. Another one would be to empty the cache just for the failing tests. A third approach would be to isolate the tests from unwanted middlewares (override_settings(MIDDLEWARE_CLASSES = ...).

The response is cached indeed. I think cleaning cache in setUp is the easiest solution.

How cache is used during running tests? During executing django.contrib.sitemaps.tests.http.HTTPSitemapTest.test_requestsite_sitemap the LocMemCache instance is used:

its method get is called with argument key='views.decorators.cache.cache_header..8e8e090224d76db794280be1b767ecc0.en-us'; it returns None;

next its method set is called with arguments key='views.decorators.cache.cache_header..8e8e090224d76db794280be1b767ecc0.en-us' and value=[];

next its method set is called one more time with arguments key='views.decorators.cache.cache_page..GET.8e8e090224d76db794280be1b767ecc0.d41d8cd98f00b204e9800998ecf8427e.en-us' and value=<django.template.response.TemplateResponse object at 0x2894a10>`; after rendering the TemplateResponse instance its content is

Then the django.contrib.sitemaps.tests.http.HTTPSitemapTest.test_simple_sitemap is run:

method get is called with argument key='views.decorators.cache.cache_header..8e8e090224d76db794280be1b767ecc0.en-us'; it returns [];

method get is called one more time with argument key='views.decorators.cache.cache_page..GET.8e8e090224d76db794280be1b767ecc0.d41d8cd98f00b204e9800998ecf8427e.en-us'; it returns <django.template.response.TemplateResponse object at 0x28d9a10> - the cached TemplateResponse instance.