# Tests Django (Django) > TestCase, test fixtures, factories, test client, coverage, TDD, mocking, CI/CD integration - 22 questions d'entretien - Confirmé - [Questions d'entretien: Django](https://sharpskill.dev/fr/technologies/django/questions-entretien.md) ## 1. Quelle classe de base utiliser pour écrire des tests unitaires dans Django ? **Réponse** django.test.TestCase est la classe de base recommandée pour les tests unitaires Django. Elle hérite de unittest.TestCase et ajoute des fonctionnalités spécifiques à Django comme le wrapping automatique des tests dans une transaction de base de données qui est annulée à la fin de chaque test, garantissant ainsi l'isolation des tests. ## 2. Quelle est la différence principale entre TestCase et TransactionTestCase dans Django ? **Réponse** TestCase encapsule les tests dans une transaction atomique qui est annulée à la fin, ce qui est plus rapide mais empêche de tester les comportements transactionnels réels. TransactionTestCase recrée la base de données entre chaque test, permettant de tester les commits et rollbacks explicites, mais est plus lent. ## 3. Comment utiliser le client de test Django pour simuler une requête GET vers une vue ? **Réponse** Le client de test Django, accessible via self.client dans un TestCase, permet de simuler des requêtes HTTP. La méthode self.client.get('/url/') simule une requête GET et retourne un objet Response contenant le status_code, le content et le context du template utilisé pour le rendu. ## 19 questions supplémentaires disponibles - Comment charger des données de test prédéfinies dans Django avec des fixtures JSON ? - Quel est l'avantage principal d'utiliser Factory Boy par rapport aux fixtures JSON ? S'inscrire gratuitement: https://sharpskill.dev/fr/login ## Autres sujets d'entretien Django - [Les bases de Python](https://sharpskill.dev/fr/technologies/django/questions-entretien/python-basics.md): 25 questions, Junior - [Python orienté objet](https://sharpskill.dev/fr/technologies/django/questions-entretien/python-oop.md): 20 questions, Junior - [Fondamentaux Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-fundamentals.md): 20 questions, Junior - [Models Django - Bases](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-models-basics.md): 22 questions, Junior - [Vues Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-views.md): 20 questions, Junior - [Templates Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-templates.md): 18 questions, Junior - [Formulaires Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-forms.md): 22 questions, Confirmé - [QuerySets avancés](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-querysets.md): 25 questions, Confirmé - [Authentification Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-authentication.md): 22 questions, Confirmé - [Middleware Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-middleware.md): 18 questions, Confirmé - [Admin Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-admin.md): 20 questions, Confirmé - [Django REST Framework](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-rest-framework.md): 30 questions, Confirmé - [Signaux Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-signals.md): 18 questions, Confirmé - [Upload de fichiers](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-file-upload.md): 20 questions, Confirmé - [Cache Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-caching.md): 20 questions, Confirmé - [Sessions Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-sessions.md): 18 questions, Confirmé - [Email Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-email.md): 18 questions, Confirmé - [Sécurité Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-security.md): 22 questions, Confirmé - [Déploiement Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-deployment.md): 24 questions, Confirmé - [ORM Django avancé](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-orm-advanced.md): 28 questions, Senior - [Performance Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-performance.md): 24 questions, Senior - [Django & Celery](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-celery.md): 22 questions, Senior - [Django Channels](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-channels.md): 24 questions, Senior - [Django & GraphQL](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-graphql.md): 24 questions, Senior - [Django & Docker](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-docker.md): 20 questions, Senior - [Django dans un écosystème Microservices](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-microservices.md): 24 questions, Senior - [Commandes Django personnalisées](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-custom-commands.md): 18 questions, Senior - [Internationalisation Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-internationalization.md): 20 questions, Senior - [Design Patterns Django](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-design-patterns.md): 24 questions, Senior - [Django Async & ASGI](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-async-asgi.md): 26 questions, Senior - [Settings & Configuration Production](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-settings-configuration.md): 22 questions, Senior - [Observabilité & Monitoring](https://sharpskill.dev/fr/technologies/django/questions-entretien/django-observability.md): 24 questions, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/fr/technologies/django/questions-entretien/django-testing