Opened 8 years ago

Closed 8 years ago

#18408 closed Bug (fixed)

flatpages - tests expect site 1 to be

Reported by: jens@… Owned by: nobody
Component: contrib.flatpages Version: 1.4
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


There is a test failure in django.contrib.flatpages that occurs when a project has customized the domain for 1.
See pull request 83 ( on GitHub with a proposed fix.

Steps to reproduce:

  1. Create a new project and app
  2. Make necessary configuration changes for flatpages, sites, and test app & syncdb
  3. Create initial_data fixture for site id 1 and update the domain to something other than (for example:
  4. Run tests
    FAIL: test_flatpage_admin_form_url_uniqueness_validation (django.contrib.flatpages.tests.forms.FlatpageAdminFormTests)
    The flatpage admin form correctly enforces url uniqueness among flatpages of the same site
    Traceback (most recent call last):
      File "/Users/jpage/Projects/Django/venv/src/django/django/contrib/flatpages/tests/", line 60, in test_flatpage_admin_form_url_uniqueness_validation
        {'__all__': [u'Flatpage with url /myflatpage1/ already exists for site']})
    AssertionError: {'__all__': [u'Flatpage with url /myflatpage1/ already exists for site']} != {'__all__': [u'Flatpage with url /myflatpage1/ already exists for site']}
    Ran 462 tests in 18.547s
    FAILED (failures=1, skipped=1)
    Destroying test database for alias 'default'...

The proposed fix adds an example_site test fixture to address the issue above. It also overrides the project's SITE_ID to 1 to address issues when running tests with a project's SITE_ID set to something other than 1. It also normalizes the use of the hard coded site id 1 to settings.SITE_ID for consistency.

Link to GitHub pull request:

Let me know if there are any changes, I am just trying to do my part and give a little back.

Change History (1)

comment:1 Changed 8 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In [ba10be70322027074e5f9defc1423eb0cc77473c]:

Fixed #18408 -- Isolated flatpages tests from existing sites.

Resolves Flatpages test issues by:

  • Creating an example_site fixture
  • Overriding project SITE_ID setting to 1
  • Normalizing the use of the hardcoded (1) site_id to settings.SITE_ID
Note: See TracTickets for help on using tickets.
Back to Top