Проблемы, чтобы покрыть тесты - PullRequest
0 голосов
/ 02 апреля 2020

Я работаю с Django 3.0.3 и создал несколько тестов для проверки моих представлений. Я хотел иметь метрики для покрытий, поэтому я установил (с pip) покрытие модуля.

С тестами проблем нет, они решают их отлично:


    >python manage.py test uMap
    Creating test database for alias 'default'...
    2020-04-02 11:10:20,748 asyncio      DEBUG    Using selector: SelectSelector
     System check identified no issues (0 silenced).
    .....
     ----------------------------------------------------------------------
    Ran 5 tests in 1.372s

     OK
     Destroying test database for alias 'default'...

Проблема это когда пытается прикрыть. Согласно документации python, способ ее запуска следующий (но она выдает ошибку в manage.py):

coverage run --source='.' manage.py test uMap
Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\core\management\__init__.py", line 377, in execute
    django.setup()
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
    class AbstractBaseUser(models.Model):
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\db\models\base.py", line 121, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
    value.contribute_to_class(cls, name)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\db\models\options.py", line 208, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\db\utils.py", line 207, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\db\utils.py", line 111, in load_backend
    return import_module('%s.base' % backend_name)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
    from .features import DatabaseFeatures
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
    from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
    from django.contrib.gis.db.models import aggregates
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
    import django.contrib.gis.db.models.functions  # NOQA
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\db\models\functions.py", line 3, in <module>
    from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
    from django.contrib.gis import forms, gdal
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
    from .fields import (  # NOQA
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\forms\fields.py", line 2, in <module>
    from django.contrib.gis.gdal import GDALException
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
    from django.contrib.gis.gdal.datasource import DataSource
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in <module>
    from django.contrib.gis.gdal.driver import Driver
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in <module>
    from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
    from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 46, in <module>
    lgdal = CDLL(lib_path)
  File "c:\users\jalvarfe\appdata\local\continuum\anaconda3\envs\py-usim\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] No se encontró el proceso especificado


Я понимаю, что это проблема из-за модуля gdal и Я не понимаю, почему это не дает мне эту ошибку при запуске тестов, но я не знаю, как это исправить. Есть идеи?

Большое спасибо

...