django/django — pull request #588 by chmarr (2012-12-14 22:29:30+00:00)
Title: Fixed #19401 - Refactored "swapped" with "is_swapped", "swapped_app_labe...

...l" and "swapped_object_name"

I've refactored the swapped check so that its checked _once_ when the options are applied to the class, and all tests for swapped-ed-ness are done against the "is_swapped", "swapped_app_label" and "swapped_object_name" attributes.

These changes cause three regression tests to fail, but these appear to be "non issues", or perhaps even fixing a limitation of the older method. All three tests were looking for a failure condition that appears to be perfectly fine code. There's insufficient documentation to know if the test _should_ have failed by design, or was failing for a known or unknown reasons.

```
======================================================================
FAIL: test_swappable_user (django.contrib.auth.tests.basic.BasicTestCase)
The current user model can be swapped out for another
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ccogdon/dev/django-1.5x/django/test/utils.py", line 213, in inner
return test_func(*args, **kwargs)
File "/Users/ccogdon/dev/django-1.5x/django/contrib/auth/tests/basic.py", line 166, in test_swappable_user
User.objects.all()
AssertionError: AttributeError not raised

======================================================================
FAIL: test_invalid_models (modeltests.invalid_models.tests.InvalidModelTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ccogdon/dev/django-1.5x/django/test/utils.py", line 213, in inner
return test_func(*args, **kwargs)
File "/Users/ccogdon/dev/django-1.5x/tests/modeltests/invalid_models/tests.py", line 48, in test_invalid_models
self.fail('Unable to load invalid model module')
AssertionError: Unable to load invalid model module

======================================================================
FAIL: test_generated_data (regressiontests.swappable_models.tests.SwappableModelTests)
Permissions and content types are not created for a swapped model
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ccogdon/dev/django-1.5x/django/test/utils.py", line 213, in inner
return test_func(*args, **kwargs)
File "/Users/ccogdon/dev/django-1.5x/tests/regressiontests/swappable_models/tests.py", line 41, in test_generated_data
self.assertNotIn(('swappable_models', 'article'), apps_models)
AssertionError: (u'swappable_models', u'article') unexpectedly found in [(u'admin', u'logentry'), (u'admin', u'logentry'), (u'admin', u'logentry'), (u'admin_ch...
```