mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-10-22 19:54:50 +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:**
|
**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.
|
||||||
If your tests require access to the database, do not forget to inherit from `django.test.TestCase`.
|
|
||||||
For example:
|
For example, with TestCase:
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
|
@ -94,6 +94,16 @@ For example:
|
||||||
# Your test code here
|
# Your test code here
|
||||||
pass
|
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.
|
You can reuse existing models defined in `tests/models.py` for your tests.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
Loading…
Reference in New Issue
Block a user