Python 3.5.0を使用してDjangoプロジェクト(Djangoバージョン1.11.4) でいくつかのテストを実行しようとしています。ValueError:テスト実行時に関連モデルu'app.model 'を解決できません
私は自分のプロジェクト内にuploadsとtestgenの2つのアプリケーションがあります。
それらは私のモデルです:
(。。ここでは関係フィールドのような唯一の特殊フィールドは、ある分野の残りは主にCharFieldです、PositiveIntegerFieldとのBooleanFieldある)
アップロード\ models.py
(簡易版)
class Document(models.Model):
(any relationship fields)
class Word(models.Model):
synonyms = models.ManyToManyField("self")
antonyms = models.ManyToManyField("self")
class Sentence(models.Model):
words = models.ManyToManyField(Word)
class Paragraph(models.Model):
sentences = models.ManyToManyField(Sentence)
class Text(models.Model):
document = models.ForeignKey(Document, on_delete=models.CASCADE)
paragraphs = models.ManyToManyField(Paragraph)
testgenの\のmodels.py
(簡易版)
class Issue(models.Model):
content = models.OneToOneField(Sentence,
related_name="issue_content",
null=True)
question = models.OneToOneField(Sentence, null=True)
class FillableIssue(Issue):
replaceable_words = models.ManyToManyField(Word)
class StatementIssue(Issue):
replaceable_words = models.ManyToManyField(Word)
class AppTest(models.Model):
text = models.ForeignKey(Text, null=True)
fillable_issues = models.ManyToManyField(FillableIssue)
statement_issues = models.ManyToManyField(StatementIssue)
testgen \ tests.py
from django.test import TestCase
from testgen.models import AppTest
class AppTestTestCase(TestCase):
def test_apptest_has_positive_number_issues(self):
"""
has_positive_number_issues() returns True
if the test's number issues is greater than zero.
"""
app_tests = AppTest.objects.get_queryset().all()
for app_test in app_tests:
self.assertIs(app_test.has_positive_number_issues(), True)
プロジェクト設定ファイル:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'uploads',
'testgen',
]
注:私はtestgenモデルの内側にアップロードモデルを使用アプリケーションロジック。
私は、モデルの名前は、トレースバックはスクリーンショットの画像に検査することができる問題(「AppTest」)
ことができることを疑います。