regression_test.py 721 B

123456789101112131415161718192021222324252627282930
  1. from pyrsistent import pmap
  2. import random
  3. import gc
  4. def test_segfault_issue_52():
  5. threshold = None
  6. if hasattr(gc, 'get_threshold'):
  7. # PyPy is lacking these functions
  8. threshold = gc.get_threshold()
  9. gc.set_threshold(1, 1, 1) # fail fast
  10. v = [pmap()]
  11. def step():
  12. depth = random.randint(1, 10)
  13. path = random.sample(range(100000), depth)
  14. v[0] = v[0].transform(path, "foo")
  15. for i in range(1000): # usually crashes after 10-20 steps
  16. while True:
  17. try:
  18. step()
  19. break
  20. except AttributeError: # evolver on string
  21. continue
  22. if threshold:
  23. gc.set_threshold(*threshold)