<s> from __future__ import absolute_import , unicode_literals <EOL> from django . utils . six import StringIO <EOL> from django . contrib . auth . models import Permission <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . core import management <EOL> from django . db . models . loading import cache <EOL> from django . test import TestCase <EOL> from django . test . utils import override_settings <EOL> from swappable_models . models import Article <EOL> class SwappableModelTests ( TestCase ) : <EOL> available_apps = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> def setUp ( self ) : <EOL> cache . _get_models_cache . clear ( ) <EOL> def tearDown ( self ) : <EOL> cache . _get_models_cache . clear ( ) <EOL> @ override_settings ( TEST_ARTICLE_MODEL = '<STR_LIT>' ) <EOL> def test_generated_data ( self ) : <EOL> "<STR_LIT>" <EOL> Permission . objects . filter ( content_type__app_label = '<STR_LIT>' ) . delete ( ) <EOL> ContentType . objects . filter ( app_label = '<STR_LIT>' ) . delete ( ) <EOL> new_io = StringIO ( ) <EOL> management . call_command ( '<STR_LIT>' , load_initial_data = False , interactive = False , stdout = new_io ) <EOL> apps_models = [ ( p . content_type . app_label , p . content_type . model ) <EOL> for p in Permission . objects . all ( ) ] <EOL> self . assertIn ( ( '<STR_LIT>' , '<STR_LIT>' ) , apps_models ) <EOL> self . assertNotIn ( ( '<STR_LIT>' , '<STR_LIT>' ) , apps_models ) <EOL> apps_models = [ ( ct . app_label , ct . model ) <EOL> for ct in ContentType . objects . all ( ) ] <EOL> self . assertIn ( ( '<STR_LIT>' , '<STR_LIT>' ) , apps_models ) <EOL> self . assertNotIn ( ( '<STR_LIT>' , '<STR_LIT>' ) , apps_models ) <EOL> @ override_settings ( TEST_ARTICLE_MODEL = '<STR_LIT>' ) <EOL> def test_case_insensitive ( self ) : <EOL> "<STR_LIT>" <EOL> try : <EOL> Article . objects . all ( ) <EOL> except AttributeError : <EOL> self . fail ( '<STR_LIT>' ) <EOL> self . assertIsNone ( Article . _meta . swapped ) </s>
