<s> import django <EOL> from django . core . management import call_command <EOL> from django . db import connection <EOL> from django . test import TestCase <EOL> from tenant_schemas . utils import get_tenant_model <EOL> from tenant_schemas . utils import get_public_schema_name <EOL> class TenantTestCase ( TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . sync_shared ( ) <EOL> tenant_domain = '<STR_LIT>' <EOL> cls . tenant = get_tenant_model ( ) ( domain_url = tenant_domain , schema_name = '<STR_LIT:test>' ) <EOL> cls . tenant . save ( verbosity = <NUM_LIT:0> ) <EOL> connection . set_tenant ( cls . tenant ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> connection . set_schema_to_public ( ) <EOL> cls . tenant . delete ( ) <EOL> cursor = connection . cursor ( ) <EOL> cursor . execute ( '<STR_LIT>' ) <EOL> @ classmethod <EOL> def sync_shared ( cls ) : <EOL> if django . VERSION >= ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:0> ) : <EOL> call_command ( '<STR_LIT>' , <EOL> schema_name = get_public_schema_name ( ) , <EOL> interactive = False , <EOL> verbosity = <NUM_LIT:0> ) <EOL> else : <EOL> call_command ( '<STR_LIT>' , <EOL> schema_name = get_public_schema_name ( ) , <EOL> tenant = False , <EOL> public = True , <EOL> interactive = False , <EOL> migrate_all = True , <EOL> verbosity = <NUM_LIT:0> , <EOL> ) </s>
