MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / test_parse

Function test_parse

tests/test_parsing.py:11–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10
11def test_parse() -> None:
12 text = "2016-10-16T12:34:56.123456+01:30"
13
14 dt = pendulum.parse(text)
15
16 assert isinstance(dt, pendulum.DateTime)
17 assert_datetime(dt, 2016, 10, 16, 12, 34, 56, 123456)
18 assert dt.tz is not None
19 assert dt.tz.name == "+01:30"
20 assert dt.offset == 5400
21
22 text = "2016-10-16"
23
24 dt = pendulum.parse(text)
25
26 assert isinstance(dt, pendulum.DateTime)
27 assert_datetime(dt, 2016, 10, 16, 0, 0, 0, 0)
28 assert dt.offset == 0
29
30 with pendulum.travel_to(pendulum.datetime(2015, 11, 12), freeze=True):
31 text = "12:34:56.123456"
32
33 dt = pendulum.parse(text)
34
35 assert isinstance(dt, pendulum.DateTime)
36 assert_datetime(dt, 2015, 11, 12, 12, 34, 56, 123456)
37 assert dt.offset == 0
38
39
40def test_parse_with_timezone() -> None:

Callers

nothing calls this directly

Calls 4

assert_datetimeFunction · 0.90
parseMethod · 0.80
travel_toMethod · 0.45
datetimeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…