Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Guest House
    • Distributeur de boissons
    • Hotel
    Real Estate
    • Real Estate Agency
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consulting
    • Accounting Firm
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Solar Energy Systems
    • Cordonnier
    • Services de nettoyage
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Odoo.sh UnitTest Print in Logs

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
logstestingunittestodoosh
1 Répondre
6333 Vues
Avatar
YME

Hello,


I am currently trying to use Unit Tests on my Odoo.sh project, but I can't seem to find my output in my logs.


My Code:

__init__.py

from . import test_example


test_example.py

# -*- coding: utf-8 -*-

# import unittest
from odoo.tests import common
# import logging

# _logger = logging.getLogg


class TestModule(common.TransactionCase):
    
#     at_install = True
#     post_install = True
    
    def setUp(self):
        super(TestModule, self).setUp()
        #Add Test Setup Code Here
        
        
    def test_data(self):
        #Add Test Code Here
        
        # Create a New Location with the Test
        test_location_1 = self.env['stock.location'].create({
            'name': 'Location_1',
            'usage':'internal'
        })
        
        # Create a Another Location
        test_location_2 = self.env['stock.location'].create({
            'name': 'Location_2',
            'usage':'storage'
        })
        
        # Check if the usage of the two created locations are the same
        
        # Assert functions are used to check whether the operation’s output is True or False
        self.assertEqual(test_location_1.usage, test_location_2.usage, msg='TEST FAILED')
        
    
#     if __name__ == '__main__':
#         unittest.main()



My question is:
How do I print my TEST FAILED message to the logs (Or anywhere else to help me identify the exact location of the error)



Any help is appreciated, thanks.

0
Avatar
Ignorer
Avatar
Michael Jurke
Meilleure réponse

I might need more information to answer your question. Is your test executed?

You need to start odoo with --test-enable and -i <your_module_with_the_test>. And I would recommend --test-tags <your_module_with_the_test> (only execute tests of your module, but not whole odoo test suite) and maybe -d test_1 --stop-after-init as well (seperate database test run).

Then, in the logs you will see

INFO test_1 odoo.addons.your_module_with_the_test.tests.test_example Starting TestModule.test_data ... 
INFO test_1 odoo.addons.your_module_with_the_test.tests.test_example: ====================================================================== 
ERROR test_1 odoo.addons.your_module_with_the_test.tests.test_example: FAIL: TestModule.test_data
Traceback (most recent call last):
  File "/path/to/your/addons/your_module_with_the_test/tests/test_example.py", line 75, in test_data
    self.assertEqual(test_location_1.usage, test_location_2.usage, msg='TEST FAILED')
AssertionError: 'internal' != 'storage'
- internal
+ storage
 : TEST FAILED 


If this does not help, I might need more information.


0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Are there any tools for analyzing the Odoo logs? Like having a report based on different events / errors over time.
performance logs testing
Avatar
Avatar
Avatar
Avatar
5
oct. 16
9549
run single unit test case Résolu
test testing tests unittest
Avatar
1
janv. 24
15173
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' when creating new staging branch Résolu
odoosh
Avatar
Avatar
Avatar
Avatar
Avatar
7
juil. 25
51738
Workflow for Pushing Changes from Odoo.sh to GitHub Without Merging to the Main Branch
odoosh
Avatar
0
déc. 24
2106
ODOO.sh Résolu
odoosh
Avatar
Avatar
Avatar
2
oct. 24
14038
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now