<s> try : <EOL> import unittest2 as unittest <EOL> except ImportError : <EOL> import unittest <EOL> import datetime <EOL> from cassandra . util import Date , Time <EOL> class DateTests ( unittest . TestCase ) : <EOL> def test_from_datetime ( self ) : <EOL> expected_date = datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:12> ) <EOL> d = Date ( expected_date ) <EOL> self . assertEqual ( str ( d ) , str ( expected_date ) ) <EOL> def test_from_string ( self ) : <EOL> expected_date = datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:12> ) <EOL> d = Date ( expected_date ) <EOL> sd = Date ( '<STR_LIT>' ) <EOL> self . assertEqual ( sd , d ) <EOL> sd = Date ( '<STR_LIT>' ) <EOL> self . assertEqual ( sd , d ) <EOL> def test_from_date ( self ) : <EOL> expected_date = datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:12> ) <EOL> d = Date ( expected_date ) <EOL> self . assertEqual ( d . date ( ) , expected_date ) <EOL> def test_from_days ( self ) : <EOL> sd = Date ( <NUM_LIT:0> ) <EOL> self . assertEqual ( sd , Date ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) ) <EOL> sd = Date ( - <NUM_LIT:1> ) <EOL> self . assertEqual ( sd , Date ( datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) ) <EOL> sd = Date ( <NUM_LIT:1> ) <EOL> self . assertEqual ( sd , Date ( datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> def test_limits ( self ) : <EOL> min_builtin = Date ( datetime . date ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> max_builtin = Date ( datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> self . assertEqual ( Date ( min_builtin . days_from_epoch ) , min_builtin ) <EOL> self . assertEqual ( Date ( max_builtin . days_from_epoch ) , max_builtin ) <EOL> self . assertEqual ( Date ( min_builtin . days_from_epoch - <NUM_LIT:1> ) . days_from_epoch , <EOL> min_builtin . days_from_epoch - <NUM_LIT:1> ) <EOL> self . assertEqual ( Date ( max_builtin . days_from_epoch + <NUM_LIT:1> ) . days_from_epoch , <EOL> max_builtin . days_from_epoch + <NUM_LIT:1> ) <EOL> def test_invalid_init ( self ) : <EOL> self . assertRaises ( ValueError , Date , '<STR_LIT>' ) <EOL> self . assertRaises ( TypeError , Date , <NUM_LIT> ) <EOL> def test_str ( self ) : <EOL> date_str = '<STR_LIT>' <EOL> self . assertEqual ( str ( Date ( date_str ) ) , date_str ) <EOL> def test_out_of_range ( self ) : <EOL> self . assertEqual ( str ( Date ( <NUM_LIT> ) ) , '<STR_LIT>' ) <EOL> self . assertEqual ( repr ( Date ( <NUM_LIT:1> ) ) , '<STR_LIT>' ) <EOL> def test_equals ( self ) : <EOL> self . assertEqual ( Date ( <NUM_LIT> ) , <NUM_LIT> ) <EOL> self . assertEqual ( Date ( <NUM_LIT:1> ) , datetime . date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> self . assertFalse ( Date ( <NUM_LIT> ) == datetime . date ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) ) <EOL> self . assertEqual ( Date ( <NUM_LIT> ) , <NUM_LIT> ) <EOL> class TimeTests ( unittest . TestCase ) : <EOL> def test_units_from_string ( self ) : <EOL> one_micro = <NUM_LIT:1000> <EOL> one_milli = <NUM_LIT:1000> * one_micro <EOL> one_second = <NUM_LIT:1000> * one_milli <EOL> one_minute = <NUM_LIT> * one_second <EOL> one_hour = <NUM_LIT> * one_minute <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , <NUM_LIT:1> ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , one_micro ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , one_milli ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , one_second ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , one_minute ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , one_hour ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , one_hour ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , <NUM_LIT> * one_hour + <NUM_LIT> * one_minute + <NUM_LIT> * one_second + <NUM_LIT> * one_milli + <NUM_LIT> * one_micro ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , <NUM_LIT> * one_hour + <NUM_LIT> * one_minute + <NUM_LIT> * one_second + <NUM_LIT> * one_milli + <NUM_LIT> * one_micro + <NUM_LIT> ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , <NUM_LIT> * one_hour + <NUM_LIT> * one_minute + <NUM_LIT> * one_second + <NUM_LIT> * one_milli + <NUM_LIT> * one_micro + <NUM_LIT> ) <EOL> tt = Time ( '<STR_LIT>' ) <EOL> self . assertEqual ( tt . nanosecond_time , <NUM_LIT> * one_hour + <NUM_LIT> * one_minute + <NUM_LIT> * one_second + <NUM_LIT> * one_milli + <NUM_LIT> * one_micro + <NUM_LIT> ) <EOL> def test_micro_precision ( self ) : <EOL> Time ( '<STR_LIT>' ) <EOL> Time ( '<STR_LIT>' ) <EOL> Time ( '<STR_LIT>' ) <EOL> Time ( '<STR_LIT>' ) <EOL> Time ( '<STR_LIT>' ) <EOL> def test_from_int ( self ) : <EOL> tt = Time ( <NUM_LIT> ) <EOL> self . assertEqual ( tt . nanosecond_time , <NUM_LIT> ) <EOL> def test_from_time ( self ) : <EOL> expected_time = datetime . time ( <NUM_LIT:12> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> tt = Time ( expected_time ) <EOL> self . assertEqual ( tt , expected_time ) <EOL> def test_equals ( self ) : <EOL> self . assertEqual ( Time ( <NUM_LIT> ) , Time ( <NUM_LIT> ) ) <EOL> def test_str_repr ( self ) : <EOL> time_str = '<STR_LIT>' <EOL> self . assertEqual ( str ( Time ( time_str ) ) , time_str ) <EOL> self . assertEqual ( repr ( Time ( <NUM_LIT:1> ) ) , '<STR_LIT>' ) <EOL> def test_invalid_init ( self ) : <EOL> self . assertRaises ( ValueError , Time , '<STR_LIT>' ) <EOL> self . assertRaises ( TypeError , Time , <NUM_LIT> ) <EOL> self . assertRaises ( ValueError , Time , <NUM_LIT> ) <EOL> self . assertRaises ( TypeError , Time , datetime . datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT:1> ) ) </s>
