File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,20 @@ pip install django pytest-unmagic flake8
25
25
26
26
pytest
27
27
flake8 --config=setup.cfg
28
+
29
+ # To run tests against postgres
30
+ pip install psycopg2-binary
31
+ psql -U username -h localhost -p 5432 -c 'create database django_cte;'
32
+ export PG_DB_SETTINGS='{
33
+ "ENGINE":"django.db.backends.postgresql_psycopg2",
34
+ "NAME":"django_cte",
35
+ "USER":"username",
36
+ "PASSWORD":"password",
37
+ "HOST":"localhost",
38
+ "PORT":"5432"}'
39
+
40
+ # WARNING pytest will delete the test_django_cte database if it exists!
41
+ DB_SETTINGS="$PG_DB_SETTINGS" pytest
28
42
```
29
43
30
44
All feature and bug contributions are expected to be covered by tests.
Original file line number Diff line number Diff line change 1
1
from __future__ import absolute_import
2
2
from __future__ import unicode_literals
3
3
4
- import sys
5
-
6
4
from django .db import connection
7
5
8
6
from .models import KeyPair , Region , Order
@@ -16,13 +14,7 @@ def init_db():
16
14
return
17
15
is_initialized = True
18
16
19
- # replace sys.stdout for prompt to delete database
20
- old_stdout = sys .stdout
21
- sys .stdout = sys .__stdout__
22
- try :
23
- connection .creation .create_test_db (verbosity = 0 )
24
- finally :
25
- sys .stdout = old_stdout
17
+ connection .creation .create_test_db (verbosity = 0 , autoclobber = True )
26
18
27
19
setup_data ()
28
20
You can’t perform that action at this time.
0 commit comments