<s> """<STR_LIT>""" <EOL> import datetime <EOL> import sys <EOL> import copy <EOL> import pickle <EOL> sys . path [ <NUM_LIT:0> : <NUM_LIT:0> ] = [ "<STR_LIT>" ] <EOL> from bson . timestamp import Timestamp <EOL> from bson . tz_util import utc <EOL> from test import unittest <EOL> class TestTimestamp ( unittest . TestCase ) : <EOL> def test_timestamp ( self ) : <EOL> t = Timestamp ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertEqual ( t . time , <NUM_LIT> ) <EOL> self . assertEqual ( t . inc , <NUM_LIT> ) <EOL> self . assertTrue ( isinstance ( t , Timestamp ) ) <EOL> def test_datetime ( self ) : <EOL> d = datetime . datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:5> , tzinfo = utc ) <EOL> t = Timestamp ( d , <NUM_LIT:0> ) <EOL> self . assertEqual ( <NUM_LIT> , t . time ) <EOL> self . assertEqual ( d , t . as_datetime ( ) ) <EOL> def test_datetime_copy_pickle ( self ) : <EOL> d = datetime . datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:5> , tzinfo = utc ) <EOL> t = Timestamp ( d , <NUM_LIT:0> ) <EOL> dc = copy . deepcopy ( d ) <EOL> self . assertEqual ( dc , t . as_datetime ( ) ) <EOL> for protocol in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , - <NUM_LIT:1> ] : <EOL> pkl = pickle . dumps ( d , protocol = protocol ) <EOL> dp = pickle . loads ( pkl ) <EOL> self . assertEqual ( dp , t . as_datetime ( ) ) <EOL> def test_exceptions ( self ) : <EOL> self . assertRaises ( TypeError , Timestamp ) <EOL> self . assertRaises ( TypeError , Timestamp , None , <NUM_LIT> ) <EOL> self . assertRaises ( TypeError , Timestamp , <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertRaises ( TypeError , Timestamp , <NUM_LIT> , None ) <EOL> self . assertRaises ( TypeError , Timestamp , <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertRaises ( ValueError , Timestamp , <NUM_LIT:0> , - <NUM_LIT:1> ) <EOL> self . assertRaises ( ValueError , Timestamp , - <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> self . assertTrue ( Timestamp ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_equality ( self ) : <EOL> t = Timestamp ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertNotEqual ( t , Timestamp ( <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> self . assertNotEqual ( t , Timestamp ( <NUM_LIT:1> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( t , Timestamp ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . assertFalse ( t != Timestamp ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> def test_hash ( self ) : <EOL> self . assertEqual ( hash ( Timestamp ( <NUM_LIT:1> , <NUM_LIT:2> ) ) , hash ( Timestamp ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> self . assertNotEqual ( hash ( Timestamp ( <NUM_LIT:1> , <NUM_LIT:2> ) ) , hash ( Timestamp ( <NUM_LIT:1> , <NUM_LIT:3> ) ) ) <EOL> self . assertNotEqual ( hash ( Timestamp ( <NUM_LIT:1> , <NUM_LIT:2> ) ) , hash ( Timestamp ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> def test_repr ( self ) : <EOL> t = Timestamp ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . assertEqual ( repr ( t ) , "<STR_LIT>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
