old_contents: import pytest
  from unittest.mock import Mock
  
  from .context import tohu
  from tohu.v3.primitive_generators import *
  
  
  exemplar_primitive_generators = [
      Constant("quux"),
      Integer(100, 200),
      HashDigest(length=6),
      FakerGenerator(method="name"),
      IterateOver('abcdefghijklmnopqrstuvwxyz'),
      SelectOne('abcdefghijklmnopqrstuvwxyz'),
  ]
  
  @pytest.mark.parametrize("g", exemplar_primitive_generators)
  def test_can_register_clones_which_are_automatically_reset(g):
      """
      Can register clones and these are automatically reset when the parent is reset
      """
      dummy_clone_1 = Mock()
      dummy_clone_2 = Mock()
      g.register_clone(dummy_clone_1)
      g.register_clone(dummy_clone_2)
  
      g.reset(seed=12345)
      dummy_clone_1.reset.assert_called_once_with(12345)
      dummy_clone_2.reset.assert_called_once_with(12345)
  
      g.reset(seed=99999)
      dummy_clone_1.reset.assert_called_with(99999)
      dummy_clone_2.reset.assert_called_with(99999)
  
  
  @pytest.mark.parametrize("g1", exemplar_primitive_generators)
  def test_spawn_generators(g1):
      """
      Generators can be spawned and the spawned versions produce the same elements.
      """
      num = 10
      g1.reset(seed=12345)
  
      # Let g1 generate a few items
      items1a = list(g1.generate(num))
  
      # Spawn g1 and let both generate a few more items
      g2 = g1.spawn()
      items1b = list(g1.generate(num))
      items2b = list(g2.generate(10))
  
      # Reset g2 and re-generate the full list of items
      g2.reset(seed=12345)
      items2 = list(g2.generate(20))
  
      # Verify that the items generated by g2 after spawning
      # as well as the full sets of items are identical.
      assert items2b == items1b
      assert items2 == items1a + items1b
  
  
new_contents: import pytest
  from unittest.mock import Mock
  
  from .context import tohu
  from tohu.v3.primitive_generators import *
  
  
  exemplar_primitive_generators = [
      Constant("quux"),
      Integer(100, 200),
      HashDigest(length=6),
      FakerGenerator(method="name"),
      IterateOver('abcdefghijklmnopqrstuvwxyz'),
      SelectOne('abcdefghijklmnopqrstuvwxyz'),
  ]
  
  @pytest.mark.parametrize("g", exemplar_primitive_generators)
  def test_can_register_clones_which_are_automatically_reset(g):
      """
      Can register clones and these are automatically reset when the parent is reset
      """
      dummy_clone_1 = Mock()
      dummy_clone_2 = Mock()
      g.register_clone(dummy_clone_1)
      g.register_clone(dummy_clone_2)
  
      g.reset(seed=12345)
      dummy_clone_1.reset.assert_called_once_with(12345)
      dummy_clone_2.reset.assert_called_once_with(12345)
  
      g.reset(seed=99999)
      dummy_clone_1.reset.assert_called_with(99999)
      dummy_clone_2.reset.assert_called_with(99999)
  
  
  @pytest.mark.parametrize("g", exemplar_primitive_generators)
  def test_spawn_generators(g):
      """
      Generators can be spawned and the spawned versions produce the same elements.
      """
      num_items = 10
      g.reset(seed=12345)
  
      # Let g generate a few items
      items_g_1 = list(g.generate(num_items))
  
      # Spawn g and let both generate a few more items
      h = g.spawn()
      items_g_2 = list(g.generate(num_items))
      items_h_2 = list(h.generate(num_items))
  
      # Reset h and re-generate the full list of items
      h.reset(seed=12345)
      items_h = list(h.generate(2*num_items))
  
      # Verify that the items generated by h after spawning
      # as well as the full sets of items are identical.
      assert items_h_2 == items_g_2
      assert items_h == items_g_1 + items_g_2
  
subject: Refactor test