File tree 1 file changed +4
-1
lines changed
pytest_postgresql/factories
1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 22
22
23
23
import psycopg
24
24
import pytest
25
+ from _pytest .scope import _ScopeName
25
26
from psycopg import Connection
26
27
from pytest import FixtureRequest
27
28
33
34
def postgresql (
34
35
process_fixture_name : str ,
35
36
dbname : Optional [str ] = None ,
37
+ scope : _ScopeName = "function" ,
36
38
load : Optional [List [Union [Callable , str , Path ]]] = None ,
37
39
isolation_level : "Optional[psycopg.IsolationLevel]" = None ,
38
40
) -> Callable [[FixtureRequest ], Iterator [Connection ]]:
39
41
"""Return connection fixture factory for PostgreSQL.
40
42
41
43
:param process_fixture_name: name of the process fixture
42
44
:param dbname: database name
45
+ :param scope: which scope the fixture should be created for
43
46
:param load: SQL, function or function import paths to automatically load
44
47
into our test database
45
48
:param isolation_level: optional postgresql isolation level
46
49
defaults to server's default
47
50
:returns: function which makes a connection to postgresql
48
51
"""
49
52
50
- @pytest .fixture
53
+ @pytest .fixture ( scope = scope )
51
54
def postgresql_factory (request : FixtureRequest ) -> Iterator [Connection ]:
52
55
"""Fixture factory for PostgreSQL.
53
56
You can’t perform that action at this time.
0 commit comments