+ print " disabling play"
+ c.disable()
+ print " scratching current track"
+ p = c.playing()
+ i = p['id']
+ c.scratch(i)
+ print " checking scratched track turned up in recent list"
+ while (p is not None and p['id'] == i):
+ time.sleep(1)
+ p = c.playing()
+ r = c.recent()
+ ts = filter(lambda t: t['id'] == i, r)
+ assert len(ts) == 1, "check scratched track appears exactly once in recent"
+ assert ts[0]['state'] == 'scratched', "checking track scratched"
+ print " waiting for scratch to complete"
+ while (p is not None and p['state'] == 'isscratch'):
+ time.sleep(1)
+ p = c.playing()
+ assert p is None, "checking nothing is playing"
+ c.random_disable()
+ assert c.random_enabled() == False
+ assert c.enabled() == False
+ c.enable()
+ assert c.enabled() == True
+ time.sleep(1)
+ p = c.playing()
+ assert p is None, "checking nothing playing when random disabled but playing enabled"
+ c.random_enable()
+ assert c.random_enabled() == True