@@ -140,38 +140,28 @@ def pytest_configure_node(self, node: Item) -> None:
140
140
node .workerinput ["randomly_seed" ] = seed # type: ignore [attr-defined]
141
141
142
142
143
- random_states : dict [int , tuple [Any , ...]] = {}
144
- np_random_states : dict [int , Any ] = {}
145
-
146
-
147
143
entrypoint_reseeds : list [Callable [[int ], None ]] | None = None
148
144
149
145
150
146
def _reseed (config : Config , offset : int = 0 ) -> int :
151
147
global entrypoint_reseeds
152
148
seed : int = config .getoption ("randomly_seed" ) + offset
153
- if seed not in random_states :
154
- random .seed (seed )
155
- random_states [seed ] = random .getstate ()
156
- else :
157
- random .setstate (random_states [seed ])
149
+
150
+ random .seed (seed )
151
+ random_state = random .getstate ()
158
152
159
153
if have_factory_boy : # pragma: no branch
160
- factory_set_random_state (random_states [ seed ] )
154
+ factory_set_random_state (random_state )
161
155
162
156
if have_faker : # pragma: no branch
163
- faker_random .setstate (random_states [ seed ] )
157
+ faker_random .setstate (random_state )
164
158
165
159
if have_model_bakery : # pragma: no branch
166
- baker_random .setstate (random_states [ seed ] )
160
+ baker_random .setstate (random_state )
167
161
168
162
if have_numpy : # pragma: no branch
169
163
numpy_seed = _truncate_seed_for_numpy (seed )
170
- if numpy_seed not in np_random_states :
171
- np_random .seed (numpy_seed )
172
- np_random_states [numpy_seed ] = np_random .get_state ()
173
- else :
174
- np_random .set_state (np_random_states [numpy_seed ])
164
+ np_random .seed (numpy_seed )
175
165
176
166
if entrypoint_reseeds is None :
177
167
eps = entry_points (group = "pytest_randomly.random_seeder" )
0 commit comments