Showing posts with label random. Show all posts
Showing posts with label random. Show all posts

Feb 2, 2012

Chaos Python

Add this into your functional tests and smoke it.
import sys, random

def chaos_trace(frame, event, arg): 
   if event == 'line' and random.random() < 0.000001: 
       raise MemoryError()
   return chaos_trace

sys.settrace(chaos_trace)
You will get some lovely random failures injected into your code. A great way to find bugs, and make sure your reasoning is sound in the face of CHAOS!