Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pytest-django-testing-postgresql
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
pytest-django-testing-postgresql
Commits
8d7730b7
Verified
Commit
8d7730b7
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Allow database configuration
parent
30887fe3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.rst
+4
-5
4 additions, 5 deletions
README.rst
pytest_django_testing_postgresql.py
+13
-3
13 additions, 3 deletions
pytest_django_testing_postgresql.py
setup.py
+2
-2
2 additions, 2 deletions
setup.py
with
19 additions
and
10 deletions
README.rst
+
4
−
5
View file @
8d7730b7
...
...
@@ -24,11 +24,10 @@ auto-discovers it).
The plugin re-uses the configuration used by `pytest-django`_.
Limitations
-----------
Right now, this plugin can only reconfigure the `default` database.
By default, only the ``default`` database is setup. You can modify this
by setting ``PYTEST_SETUP_DATABASES`` to a list of database aliases in
your ``settings`` module. The list can contain strings, or tuples if you
want some aliases to share the same database backend.
.. _testing.postgresql: https://pypi.org/project/testing.postgresql/
.. _pytest-django: https://pypi.org/project/pytest-django/
This diff is collapsed.
Click to expand it.
pytest_django_testing_postgresql.py
+
13
−
3
View file @
8d7730b7
...
...
@@ -5,13 +5,23 @@ from django.conf import settings
import
pytest
from
testing.postgresql
import
Postgresql
_POSTGRESQL
=
Postgresql
()
_POSTGRESQL
S
=
[]
@pytest.hookimpl
(
tryfirst
=
True
)
def
pytest_load_initial_conftests
(
early_config
,
parser
,
args
):
os
.
environ
[
'
DJANGO_SETTINGS_MODULE
'
]
=
early_config
.
getini
(
'
DJANGO_SETTINGS_MODULE
'
)
settings
.
DATABASES
[
'
default
'
]
=
parse
(
_POSTGRESQL
.
url
())
db_sets
=
getattr
(
settings
,
"
PYTEST_SETUP_DATABASES
"
,
[(
"
default
"
,)])
for
db_set
in
db_sets
:
postgresql
=
Postgresql
()
if
isinstance
(
db_set
,
str
):
db_set
=
[
db_set
]
for
db
in
db_set
:
settings
.
DATABASES
[
db
]
=
parse
(
postgresql
.
url
())
_POSTGRESQLS
.
append
(
postgresql
)
def
pytest_unconfigure
(
config
):
_POSTGRESQL
.
stop
()
for
postgresql
in
_POSTGRESQLS
:
postgresql
.
stop
()
This diff is collapsed.
Click to expand it.
setup.py
+
2
−
2
View file @
8d7730b7
...
...
@@ -8,7 +8,7 @@ with open(path.join(this_directory, 'README.rst'), encoding='utf-8') as f:
setup
(
name
=
"
pytest-django-testing-postgresql
"
,
version
=
'
0.
1.post0
'
,
version
=
'
0.
2
'
,
description
=
'
Use a temporary PostgreSQL database with pytest-django
'
,
long_description
=
long_description
,
author
=
'
Dominik George
'
,
...
...
@@ -16,7 +16,7 @@ setup(
url
=
'
https://edugit.org/AlekSIS/libs/pytest-django-testing-postgresql
'
,
classifiers
=
[
'
Development Status ::
3
-
Alph
a
'
,
'
Development Status ::
4
-
Bet
a
'
,
'
Framework :: Django
'
,
'
Framework :: Pytest
'
,
'
Intended Audience :: Developers
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment