Skip to content

Commit 1fc2af7

Browse files
committed
Test copied globally-seeded RandObj
- Ensure deepcopy is possible. - Expose determinism bugs.
1 parent a92088b commit 1fc2af7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/testutils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ def test_randobj(self) -> None:
233233
# Test using global seeding, ensuring results are the same
234234
random.seed(0)
235235
randobj0_global = self.get_randobj()
236+
# Take a copy for later
237+
randobj0_global_copy = deepcopy(randobj0_global)
236238
self.randomize_and_check_result(
237239
randobj0_global,
238240
results,
@@ -259,3 +261,18 @@ def test_randobj(self) -> None:
259261
add_results,
260262
add_tmp_constraints=False,
261263
)
264+
265+
# Test the copied globally-seeded object
266+
# Must re-seed the global random package to ensure repeatability
267+
random.seed(0)
268+
self.randomize_and_check_result(
269+
randobj0_global_copy,
270+
results,
271+
do_tmp_checks,
272+
tmp_constraints,
273+
tmp_values,
274+
tmp_results,
275+
post_tmp_results,
276+
add_results,
277+
add_tmp_constraints=False,
278+
)

0 commit comments

Comments
 (0)