I'm using Python 3.7, Django, within PyCharm 2018.2.4. I have loaded my project in PyCharm and have opened my file, ./mainpage/tests.py, which is
from django.test import TestCase
from mainpage.models import ArticleStat, Article
import unittest
class TestModels(unittest.TestCase):
fixtures = ['/mainpage/fixtures/test_data.yaml',]
# Test saving an article stat that hasn't previously
# existed
def test_add_articlestat(self):
id = 1
article = Article.objects.filter(id=id)
self.assertTrue(article, "A pre-condition of this test is that an article exist with id=" + str(id))
articlestat = ArticleStat(article=article,elapsed_time_in_seconds=250,votes=25,comments=15)
articlestat.save()
article_stat = ArticleStat.objects.get(article=article)
self.assertTrue(article_stat, "Failed to svae article stat properly.")
I want to run this test file in PyCharm. I go to the "Run" menu and select "Run unit tests for Tests.models." But I get this error
Error running 'Unittests for tests.TestModels': Can't find file where tests.TestModels declared. Make sure it is in project roo
What do I need to do in PyCharm in order to run my tests within the IDE?