+def now():
+ """Return the current time in whole seconds"""
+ return int(time.time())
+
+def next_playing(c):
+ print " waiting for track to play"
+ p = c.playing()
+ waited = 0
+ while p is None and waited < 10:
+ time.sleep(1)
+ print " ."
+ p = c.playing()
+ assert waited < 10, "track played in a reasonable time"
+ return p
+
+def wait_idle(c):
+ print " waiting for nothing to be playing"
+ p = c.playing()
+ waited = 0
+ while p is not None and waited < 20:
+ time.sleep(1)
+ print " ."
+ p = c.playing()
+ assert waited < 20, "idled in a reasonable time"
+