test running problem

if create new django project. Set database params. Create database.

With empty file models.py test runing ok.

Adding any models:

class Person(models.Model):

    "Физическое лицо"

    family = models.CharField(u"Фамилия", max_length=100)

    name = models.CharField(u"Имя", max_length=100)

    surname = models.CharField(u"Отчество", max_length=100)

syncdb - create table
Run test in folder with django project - error!!!
C:\Python26\python.exe "C:\Program Files\JetBrains\PyCharm 1.1.1\helpers\pycharm\utrunner.py" D:/Py/NewSite/
Testing started at 16:54 ...
/ from folder D:/Py/NewSite/
/ Loading D:/Py/NewSite/manage.py as manage
/ Loading D:/Py/NewSite/settings.py as settings
/ Loading D:/Py/NewSite/urls.py as urls
/ Loading D:/Py/NewSite/__init__.py as __init__
/ Loading D:/Py/NewSite/newsite\models.py as models
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 1.1.1\helpers\pycharm\utrunner.py", line 113, in <module>
    modules = loadModulesFromFolderRec(a[0])
  File "C:\Program Files\JetBrains\PyCharm 1.1.1\helpers\pycharm\utrunner.py", line 72, in loadModulesFromFolderRec
    os.path.walk(folder, walkModules, modules)
  File "C:\Python26\lib\ntpath.py", line 263, in walk
    walk(name, func, arg)
  File "C:\Python26\lib\ntpath.py", line 259, in walk
    func(arg, top, names)
  File "C:\Program Files\JetBrains\PyCharm 1.1.1\helpers\pycharm\utrunner.py", line 61, in walkModules
    modules.append(loadSource(os.path.join(dirname, name)))
  File "C:\Program Files\JetBrains\PyCharm 1.1.1\helpers\pycharm\utrunner.py", line 36, in loadSource
    module = imp.load_source(moduleName, fileName)
  File "D:/Py/NewSite/newsite\models.py", line 7, in <module>
    class Person(models.Model):
  File "C:\Python26\lib\site-packages\django-1.2.5-py2.6.egg\django\db\models\base.py", line 53, in __new__
    kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range
Empty test suite.
Process finished with exit code 1
Problem in file django.db.model.base
class ModelBase(type):
    """
    Metaclass for all models.
    """
    def __new__(cls, name, bases, attrs):
line 52            kwargs = {"app_label": model_module.__name__.split('.')[-2]}
When importing with testcase file imported as models!!!!
model_module.__name__ = 'models'
If replace line 52
import os.path
label = os.path.basename(os.path.dirname(model_module.__file__))
kwargs = {"app_label": label}
All working OK??
1 comment
Comment actions Permalink

Hi, Slava.

We'll fix this problem in PyCharm 1.2.

By the way:

Django framework has its own tests and PyCharm is fully support it.

So it's more convenient to use Django test run configuration.

--
Ekaterina Tuzova
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure! "

0

Please sign in to leave a comment.