mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-10-22 03:34:24 +03:00
Update contributing guidelines to include pytest decorator for database tests
This commit is contained in:
parent
9da97c90f8
commit
542d4dc388
|
@ -83,9 +83,9 @@ To run the tests, clone the repository, and then:
|
|||
|
||||
---
|
||||
|
||||
**Note:**
|
||||
If your tests require access to the database, do not forget to inherit from `django.test.TestCase`.
|
||||
For example:
|
||||
**Note:** if your tests require access to the database, do not forget to inherit from `django.test.TestCase` or use the `@pytest.mark.django_db()` decorator.
|
||||
|
||||
For example, with TestCase:
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
@ -94,6 +94,16 @@ For example:
|
|||
# Your test code here
|
||||
pass
|
||||
|
||||
Or with decorator:
|
||||
|
||||
import pytest
|
||||
|
||||
@pytest.mark.django_db()
|
||||
class MyDatabaseTest:
|
||||
def test_something(self):
|
||||
# Your test code here
|
||||
pass
|
||||
|
||||
You can reuse existing models defined in `tests/models.py` for your tests.
|
||||
|
||||
---
|
||||
|
|
Loading…
Reference in New Issue
Block a user