@@ -287,9 +287,7 @@ def test_flex_values(test_store):
287287def test_contains (test_store ):
288288 box = test_store .box (TestEntity )
289289
290- box .put (TestEntity (str = "Object 1" ))
291- box .put (TestEntity (str = "Object 2" ))
292- box .put (TestEntity (str = "Object 3" ))
290+ box .put ([TestEntity (str = f"Object { i } " ) for i in range (1 , 4 )])
293291 assert box .count () == 3
294292
295293 assert box .contains (1 )
@@ -305,14 +303,13 @@ def test_contains(test_store):
305303def test_update (test_store ):
306304 box = test_store .box (TestEntity )
307305
308- box .put (TestEntity (str = "Object 1" ))
309- box .put (TestEntity (str = "Object 2" ))
310- box .put (TestEntity (str = "Object 3" ))
306+ box .put ([TestEntity (str = f"Object { i } " ) for i in range (1 , 4 )])
311307 assert box .count () == 3
312308
313- for obj in box .get_all ():
314- obj .str += " (updated)"
315- box .update (obj )
309+ with test_store .write_tx ():
310+ for obj in box .get_all ():
311+ obj .str += " (updated)"
312+ box .update (obj )
316313
317314 assert box .get (1 ).str == "Object 1 (updated)"
318315 assert box .get (2 ).str == "Object 2 (updated)"
@@ -332,11 +329,7 @@ def test_update(test_store):
332329def test_get_many (test_store ):
333330 box = test_store .box (TestEntity )
334331
335- box .put (TestEntity (str = "Object 1" ))
336- box .put (TestEntity (str = "Object 2" ))
337- box .put (TestEntity (str = "Object 3" ))
338- box .put (TestEntity (str = "Object 4" ))
339- box .put (TestEntity (str = "Object 5" ))
332+ box .put ([TestEntity (str = f"Object { i } " ) for i in range (1 , 6 )])
340333 assert box .count () == 5
341334
342335 objects = box .get_many ([1 , 3 , 4 ])
0 commit comments