def test_roll_generic_counter(self):
        # rough sleep to get us back on track
        time.sleep(2 - (int(time.time()) % 2))
        counter = Counter(key='test_key', window=2, cycle_time=.1, roll=True)
        counter.setup(redis_conn=self.redis_conn)
        i = 0
        while i < 100:
            counter.increment()
            i += 1
        self.assertEqual(counter.value(), 100)
        time.sleep(3)
        # now the counter should have rolled
        i = 0
        while i < 50:
            counter.increment()
            i += 1
        self.assertEqual(counter.value(), 50)
        counter.stop()
        self.clean_keys(counter.key)
dataset/ETHPy150Open istresearch/scrapy-cluster/utils/tests/tests_online.py/TestStatsCounter.test_roll_generic_counter/original