test_chrono.py (11986:c12e4625ab56) test_chrono.py (12037:d28054ac6ec9)
1
2
3def test_chrono_system_clock():
4 from pybind11_tests import test_chrono1
5 import datetime
6
7 # Get the time from both c++ and datetime
8 date1 = test_chrono1()

--- 90 unchanged lines hidden (view full) ---

99
100 # They should be identical (no information lost on roundtrip)
101 assert time1.days == time2.days
102 assert time1.seconds == time2.seconds
103 assert time1.microseconds == time2.microseconds
104
105
106def test_floating_point_duration():
1
2
3def test_chrono_system_clock():
4 from pybind11_tests import test_chrono1
5 import datetime
6
7 # Get the time from both c++ and datetime
8 date1 = test_chrono1()

--- 90 unchanged lines hidden (view full) ---

99
100 # They should be identical (no information lost on roundtrip)
101 assert time1.days == time2.days
102 assert time1.seconds == time2.seconds
103 assert time1.microseconds == time2.microseconds
104
105
106def test_floating_point_duration():
107 from pybind11_tests import test_chrono7
107 from pybind11_tests import test_chrono7, test_chrono_float_diff
108 import datetime
109
110 # Test using 35.525123 seconds as an example floating point number in seconds
111 time = test_chrono7(35.525123)
112
113 assert isinstance(time, datetime.timedelta)
114
115 assert time.seconds == 35
116 assert 525122 <= time.microseconds <= 525123
108 import datetime
109
110 # Test using 35.525123 seconds as an example floating point number in seconds
111 time = test_chrono7(35.525123)
112
113 assert isinstance(time, datetime.timedelta)
114
115 assert time.seconds == 35
116 assert 525122 <= time.microseconds <= 525123
117
118 diff = test_chrono_float_diff(43.789012, 1.123456)
119 assert diff.seconds == 42
120 assert 665556 <= diff.microseconds <= 665557