mardi 1 octobre 2019

Configure Python to Complex Django Project

I need to configure pytest in my django application. But the structure of the directories is different of what I'm used to.

.
├── apps
│   ├── __pycache__
│   ├── admcore 
│   ├── ...
│   ├── cauth 
│   ├── webservice
│   └── webshell
├── doc
│   └── ...
├── lib 
│   └── ...
├── ...
└── project  
     ├── __init__.py  
     ├── globalsettings.py 
     ├── local
     │   ├── __init__.py  
     │   ├── app.uwsgi 
     │   ├── manage.py 
     │   ├── settings.py  
     │   └── wsgi.py
     ├── mailconf.py 
     └── urls.py 

I created pytest.ini

[pytest]
DJANGO_SETTINGS_MODULE=sgp.local.test_settings
addopts = --nomigrations --cov=. --cov-report=html 

and test_settings.py files

#!/usr/bin/env python
import os
import sys
from project import globalsettings

SECRET_KEY = "12341234AFDQFDQSDFAZR123D" 

ROOT_PATH = '/usr/local/sgp'
BASEURL_ROOT = ''

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': ':memory:'
    }
}

And I put the two files in project directory.

.
├── apps
│   ├── __pycache__
│   ├── admcore 
│   ├── ...
│   ├── cauth 
│   ├── webservice
│   └── webshell
├── doc
│   └── ...
├── lib 
│   └── ...
├── ...
└── project  
     ├── __init__.py  
     ├── globalsettings.py 
     ├── local
     │   ├── __init__.py  
     │   ├── app.uwsgi 
     │   ├── manage.py
     │   ├── pytest.ini
     │   ├── settings.py 
     │   ├── test_settings.py
     │   └── wsgi.py
     ├── mailconf.py 
     └── urls.py 

But it doesn't work as I expected. I have one test in webservice app, but when I run pytest command I got:

platform darwin -- Python 3.7.4, pytest-5.2.0, py-1.8.0, pluggy-0.13.0
Django settings: project.local.test_settings (from environment variable)
rootdir: /project/local, inifile: pytest.ini
plugins: django-3.5.1, cov-2.7.1
collected 0 items


---------- coverage: platform darwin, python 3.7.4-final-0 -----------
Coverage HTML written to dir htmlcov

=========================================================================================================== no tests ran in 0.15s ============================================================================================================

I have no ideia how to configure pytest to this project.

Aucun commentaire:

Enregistrer un commentaire