File: test_vendor.py

package info (click to toggle)
pipenv 2024.0.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,568 kB
  • sloc: python: 187,163; makefile: 191; javascript: 133; sh: 64
file content (45 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# We need to import the patched packages directly from sys.path, so the
# identity checks can pass.
import pipenv  # noqa

import datetime


import pytest
import pytz
from pipenv.vendor import tomlkit


@pytest.mark.parametrize('dt, content', [
    (   # Date.
        datetime.date(1992, 8, 19),
        '1992-08-19',
    ),
    (   # Naive time.
        datetime.time(15, 10),
        '15:10:00',
    ),
    (   # Aware time in UTC.
        datetime.time(15, 10, tzinfo=pytz.UTC),
        '15:10:00+00:00',
    ),
    (   # Aware local time.
        datetime.time(15, 10, tzinfo=pytz.FixedOffset(8 * 60)),
        '15:10:00+08:00',
    ),
    (   # Naive datetime.
        datetime.datetime(1992, 8, 19, 15, 10),
        '1992-08-19T15:10:00',
    ),
    (   # Aware datetime in UTC.
        datetime.datetime(1992, 8, 19, 15, 10, tzinfo=pytz.UTC),
        '1992-08-19T15:10:00Z',
    ),
    (   # Aware local datetime.
        datetime.datetime(1992, 8, 19, 15, 10, tzinfo=pytz.FixedOffset(8 * 60)),
        '1992-08-19T15:10:00+08:00',
    ),
])
def test_token_date(dt, content):
    item = tomlkit.item(dt)
    assert item.as_string() == content