<s> import sys <EOL> import time <EOL> import unittest2 as unittest <EOL> from pyspider . libs import counter <EOL> class TestCounter ( unittest . TestCase ) : <EOL> def test_010_TimebaseAverageEventCounter ( self ) : <EOL> c = counter . TimebaseAverageEventCounter ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> for i in range ( <NUM_LIT:100> ) : <EOL> time . sleep ( <NUM_LIT:0.1> ) <EOL> c . event ( <NUM_LIT:100> + i ) <EOL> self . assertEqual ( c . sum , float ( <NUM_LIT> + <NUM_LIT> ) * <NUM_LIT:20> / <NUM_LIT:2> ) <EOL> self . assertEqual ( c . avg , float ( <NUM_LIT> + <NUM_LIT> ) / <NUM_LIT:2> ) <EOL> def test_020_delete ( self ) : <EOL> c = counter . CounterManager ( ) <EOL> c . event ( ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <NUM_LIT:1> ) <EOL> c . event ( ( '<STR_LIT:a>' , '<STR_LIT:c>' ) , <NUM_LIT:1> ) <EOL> c . event ( ( '<STR_LIT:b>' , '<STR_LIT:c>' ) , <NUM_LIT:1> ) <EOL> self . assertIsNotNone ( c [ '<STR_LIT:a>' ] ) <EOL> self . assertIsNotNone ( c [ '<STR_LIT:b>' ] ) <EOL> del c [ '<STR_LIT:a>' ] <EOL> self . assertNotIn ( '<STR_LIT:a>' , c ) <EOL> self . assertIsNotNone ( c [ '<STR_LIT:b>' ] ) </s>
