Seite 1 von 1

pytest: overage.py warning: Module projekt was never imported. (module-not-imported)

Verfasst: Mittwoch 1. Mai 2019, 18:20
von nieselfriem
Hallo,

ich versuche mich gerade in Unittest. Dazu verwende ich pytest und ich habe folgenden Test geschrieben:

Code: Alles auswählen

import pytest
import datetime

from databaseoperations.db_operations import *

con = DBConnect()

@db_session
def test_customer_order():
    db = DatabaseOperations()
    sel =db.get_best_list(45)
    for infos in sel:
        assert infos == ([62, '20190331165945', datetime.date(datetime(2019,3,31)), 20135, 0])
Ich bekomme jedoch folgende Fehlermeldung:

Code: Alles auswählen

 python3 -m pytest tests/test_choice_customer_order.py 
========================================================================================================================== test session starts ==========================================================================================================================
platform linux -- Python 3.6.7, pytest-4.3.0, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/georg/PycharmProjects/abu_2019, inifile: setup.cfg
plugins: cov-2.6.1
collected 1 item                                                                                                                                                                                                                                                        

tests/test_choice_customer_order.py::test_customer_order PASSED                                                                                                                                                                                                   [100%]Coverage.py warning: Module abu2019 was never imported. (module-not-imported)
Coverage.py warning: No data was collected. (no-data-collected)
WARNING: Failed to generate report: No data to report.

/home/georg/.local/lib/python3.6/site-packages/pytest_cov/plugin.py:229: PytestWarning: Failed to generate report: No data to report.

  self.cov_controller.finish()


----------- coverage: platform linux, python 3.6.7-final-0 -----------
Name    Stmts   Miss  Cover   Missing
-------------------------------------
ich habe folgende Ordnerstruktur:

Code: Alles auswählen

abu_2019
├── data
├── databaseoperations
│   └── __pycache__
├── docandreportcreation
│   ├── __pycache__
│   └── templates
├── docs
│   └── _static
├── formattools
│   └── __pycache__
├── htmlcov
├── initui
│   └── __pycache__
├── iooperations
│   └── __pycache__
├── logs
├── mylogging
│   └── __pycache__
├── ostools
│   └── __pycache__
├── prototypen
│   ├── create_bill
│   └── savepdfdb
│       └── __pycache__
├── __pycache__
├── QtComponents
│   └── __pycache__
├── README.rst
├── requirements.txt
├── setup.cfg
├── setup.py
├── skeleton.py
├── src
│   └── abu2019
├── tests
│   └── __pycache__
├── ui
│   ├── dialogs
│   │   └── __pycache__
│   └── __pycache__
└── uioperations
    └── __pycache__

Was und wie soll ich denn da noch Importieren, damit er mir einen "Report" ausgibt?

VG niesel

Re: pytest: overage.py warning: Module projekt was never imported. (module-not-imported)

Verfasst: Mittwoch 1. Mai 2019, 20:01
von __blackjack__
@nieselfriem: Du müsstest dazu wohl `pytest` die Tests im gesamten Projekt suchen lassen und nicht direkt das Testmodul angeben.

Wo kommt die Meldung aus dem Betreff eigentlich her? Das ist ja eine andere als die im Beitrag selbst.