-
-
Save anonymous/a11898d0cd8ffc78b531 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setUp(self): | |
_exists = False | |
for _model in apps.get_models(): | |
if getattr(_model, '_test_eggs', False): | |
_exists = True | |
self.Eggs = _model | |
if getattr(_model, '_test_spam', False): | |
_exists = True | |
self.Spam = _model | |
# Check whether the models exist, and short circuit, if so | |
if _exists: | |
return | |
class Eggs(AccountModel): | |
_test_eggs = True # To denote that this is a test model | |
pass | |
class Spam(AccountModel): | |
_test_spam = True # To denote that this is a test model | |
eggs = models.ForeignKey(Eggs) | |
ham = models.CharField(max_length=255) | |
chicken = models.CharField(max_length=255) | |
steak = models.CharField(_(u'verbose steak'), max_length=255) | |
self.Eggs = Eggs | |
self.Spam = Spam |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment