File: test_backends.py

package info (click to toggle)
python-django-timezone-field 7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: python: 1,047; sh: 6; makefile: 3
file content (26 lines) | stat: -rw-r--r-- 712 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
from django import VERSION

from timezone_field.backends import USE_PYTZ_DEFAULT, get_tz_backend
from timezone_field.backends.zoneinfo import ZoneInfoBackend


def test_use_pytz_default_USE_DEPRECATED_PYTZ_unset():
    assert USE_PYTZ_DEFAULT is (VERSION < (4, 0))


def test_get_tz_backend_when_use_pytz_is_none():
    assert get_tz_backend(None) is get_tz_backend(USE_PYTZ_DEFAULT)


def test_get_tz_backend_when_use_pytz_is_false():
    assert isinstance(get_tz_backend(False), ZoneInfoBackend)


try:
    from timezone_field.backends.pytz import PYTZBackend
except ImportError:
    pass
else:

    def test_get_tz_backend_when_use_pytz_is_true():
        assert isinstance(get_tz_backend(True), PYTZBackend)