Skip to content

Commit 6635365

Browse files
authored
Merge pull request #249 from pytest-dev/fix-2.8
Fix version 2.8.0 being incompatible with combo of python < 3.12 and factoryboy < 3.3
2 parents 3bb755d + d38c410 commit 6635365

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

CHANGES.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ Fixed
2727
Security
2828
++++++++
2929

30+
2.8.1
31+
----------
32+
33+
Added
34+
+++++
35+
* Test against all supported ``factory-boy`` versions
36+
37+
Changed
38+
+++++++
39+
40+
Deprecated
41+
++++++++++
42+
43+
Removed
44+
+++++++
45+
46+
Fixed
47+
+++++
48+
* Fix incompatibility when using the combination of python < 3.12 and factory-boy < 3.3.
49+
50+
* The error was: ``TypeError: type 'Factory' is not subscriptable``
51+
52+
Security
53+
++++++++
54+
3055
2.8.0
3156
----------
3257

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pytest-factoryboy"
3-
version = "2.8.0"
3+
version = "2.8.1"
44
description = "Factory Boy support for pytest."
55
authors = [ { name = "Oleg Pidsadnyi", email= "oleg.pidsadnyi@gmail.com" } ]
66
maintainers = [ { name = "Alessio Bogon", email = "778703+youtux@users.noreply.github.com" } ]

src/pytest_factoryboy/fixture.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,14 @@ def model_fixture(request: SubRequest, factory_name: str) -> object:
368368

369369
factory_class: type[Factory[object]] = request.getfixturevalue(factory_name)
370370

371-
# Create model fixture instance
372-
NewFactory: type[Factory[object]] = cast(type[Factory[object]], type("Factory", (factory_class,), {}))
371+
# create Factory override for the model fixture
372+
NewFactory: type[Factory[object]] = type("Factory", (factory_class,), {})
373373
# equivalent to:
374374
# class Factory(factory_class):
375375
# pass
376+
# NewFactory = Factory
377+
# del Factory
378+
376379
# it just makes mypy understand it.
377380

378381
NewFactory._meta.base_declarations = {

tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
distshare = {homedir}/.tox/distshare
33
envlist = py{3.9,3.10,3.11,3.12,3.13,3.14}-pytest{7.3,7.4,8.0,8.1,8.2,8.3,8.4,latest,main}
44
py{3.9,3.10,3.11}-pytest{7.0,7.1,7.2}
5+
py{3.9,3.10,3.11,3.12,3.13,3.14}-factoryboy{2.10,2.11,2.12,3.0,3.1,3.2,3.3,latest,main}
56

67
[testenv]
78
parallel_show_output = true
@@ -22,6 +23,16 @@ deps =
2223
pytest7.1: pytest~=7.1.0
2324
pytest7.0: pytest~=7.0.0
2425

26+
factoryboylatest: factory-boy
27+
factoryboymain: git+https://github.com/FactoryBoy/factory_boy.git@master
28+
factoryboy3.3: factory-boy~=3.3.0
29+
factoryboy3.2: factory-boy~=3.2.0
30+
factoryboy3.1: factory-boy~=3.1.0
31+
factoryboy3.0: factory-boy~=3.0.0
32+
factoryboy2.12: factory-boy~=2.12.0
33+
factoryboy2.11: factory-boy~=2.11.0
34+
factoryboy2.10: factory-boy~=2.10.0
35+
2536
coverage[toml]
2637

2738
[pytest]

0 commit comments

Comments
 (0)