text: import pytest
  
  from imitation.util import util
  
  
  def test_endless_iter():
      x = range(2)
      it = util.endless_iter(x)
      assert next(it) == 0
      assert next(it) == 1
      assert next(it) == 0
  
  
  def test_endless_iter_error():
      x = []
      with pytest.raises(ValueError, match="no elements"):
          util.endless_iter(x)
  