1

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?

Dave
  • 17,420
  • 96
  • 300
  • 582
  • I assume you don't have *PyCharm **Community** Edition*, as this error seems to be after the point that ran into in [\[SO\]: Run/Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition?](https://stackoverflow.com/questions/42989471/run-debug-a-django-applications-unittests-from-the-mouse-right-click-context-me) – CristiFati Jan 31 '19 at 10:17

0 Answers0