Skip to content

Commit d821171

Browse files
authored
Merge pull request #889 from ClearcodeHQ/deprecate-client-load
Deprecate load on client fixture - closes #850
2 parents d65c2d6 + d09d383 commit d821171

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

newsfragments/850.deprecate.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Deprecated load parameter on a client fixture.
2+
Developers are encouraged to either use the load function/parameter
3+
for process fixture, or create an intermediate fixture placed between client
4+
and tests themselves to fill in the data.

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ showcontent = true
9494
name = "Bugfixes"
9595
showcontent = true
9696

97+
[tool.towncrier.fragment.deprecate]
98+
name = "Deprecations"
99+
showcontent = true
100+
97101
[tool.towncrier.fragment.break]
98102
name = "Breaking changes"
99103
showcontent = true
100104

101105
[tool.towncrier.fragment.misc]
102106
name = "Miscellaneus"
103-
showcontent = true
107+
showcontent = false
104108

105109
[tool.tbump.version]
106110
current = "5.1.0"

pytest_postgresql/factories/client.py

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with pytest-dbfixtures. If not, see <http://www.gnu.org/licenses/>.
1818
"""Fixture factory for postgresql client."""
19+
import warnings
1920
from pathlib import Path
2021
from typing import Callable, Iterator, List, Optional, Union
2122

@@ -64,6 +65,16 @@ def postgresql_factory(request: FixtureRequest) -> Iterator[Connection]:
6465
pg_options = proc_fixture.options
6566
pg_db = dbname or proc_fixture.dbname
6667
pg_load = load or []
68+
if pg_load:
69+
warnings.warn(
70+
message=(
71+
"Load is deprecated on a client fixture. "
72+
"You should either process fixture load parameter to pre-fill database, "
73+
"or add a fixture between client and a test, "
74+
"that will fill the database with the data."
75+
),
76+
category=DeprecationWarning,
77+
)
6778

6879
with DatabaseJanitor(
6980
pg_user, pg_host, pg_port, pg_db, proc_fixture.version, pg_password, isolation_level

0 commit comments

Comments
 (0)