MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_chrono_system_clock

Function test_chrono_system_clock

tests/test_chrono.py:11–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10
11def test_chrono_system_clock():
12 # Get the time from both c++ and datetime
13 date0 = datetime.datetime.today()
14 date1 = m.test_chrono1()
15 date2 = datetime.datetime.today()
16
17 # The returned value should be a datetime
18 assert isinstance(date1, datetime.datetime)
19
20 # The numbers should vary by a very small amount (time it took to execute)
21 diff_python = abs(date2 - date0)
22 diff = abs(date1 - date2)
23
24 # There should never be a days difference
25 assert diff.days == 0
26
27 # Since datetime.datetime.today() calls time.time(), and on some platforms
28 # that has 1 second accuracy, we compare this way
29 assert diff.seconds <= diff_python.seconds
30
31
32def test_chrono_system_clock_roundtrip():

Callers

nothing calls this directly

Calls 2

isinstanceFunction · 0.85
absFunction · 0.85

Tested by

no test coverage detected