This file is indexed.

/usr/lib/python3/dist-packages/tzlocal/tests.py is in python3-tzlocal 1.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import sys
import os
from datetime import datetime
import unittest
import pytz
import tzlocal.unix

class TzLocalTests(unittest.TestCase):
    def setUp(self):
        if 'TZ' in os.environ:
            del os.environ['TZ']

    def test_env(self):
        tz_harare = tzlocal.unix._tz_from_env(':Africa/Harare')
        self.assertEqual(tz_harare.zone, 'Africa/Harare')

        # Some Unices allow this as well, so we must allow it:
        tz_harare = tzlocal.unix._tz_from_env('Africa/Harare')
        self.assertEqual(tz_harare.zone, 'Africa/Harare')

        local_path = os.path.split(__file__)[0]
        tz_local = tzlocal.unix._tz_from_env(':' + os.path.join(local_path, 'test_data', 'Harare'))
        self.assertEqual(tz_local.zone, 'local')
        # Make sure the local timezone is the same as the Harare one above.
        # We test this with a past date, so that we don't run into future changes
        # of the Harare timezone.
        dt = datetime(2012, 1, 1, 5)
        self.assertEqual(tz_harare.localize(dt), tz_local.localize(dt))

        # Non-zoneinfo timezones are not supported in the TZ environment.
        self.assertRaises(pytz.UnknownTimeZoneError, tzlocal.unix._tz_from_env, 'GMT+03:00')

    def test_timezone(self):
        # Most versions of Ubuntu
        local_path = os.path.split(__file__)[0]
        tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'timezone'))
        self.assertEqual(tz.zone, 'Africa/Harare')

    def test_zone_setting(self):
        # A ZONE setting in /etc/sysconfig/clock, f ex CentOS
        local_path = os.path.split(__file__)[0]
        tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'zone_setting'))
        self.assertEqual(tz.zone, 'Africa/Harare')

    def test_timezone_setting(self):
        # A ZONE setting in /etc/conf.d/clock, f ex Gentoo
        local_path = os.path.split(__file__)[0]
        tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'timezone_setting'))
        self.assertEqual(tz.zone, 'Africa/Harare')

    def test_symlink_localtime(self):
        # A ZONE setting in the target path of a symbolic linked localtime, f ex systemd distributions
        local_path = os.path.split(__file__)[0]
        tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'symlink_localtime'))
        self.assertEqual(tz.zone, 'Africa/Harare')

    def test_vardbzoneinfo_setting(self):
        # A ZONE setting in /etc/conf.d/clock, f ex Gentoo
        local_path = os.path.split(__file__)[0]
        tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'vardbzoneinfo'))
        self.assertEqual(tz.zone, 'Africa/Harare')

    def test_only_localtime(self):
        local_path = os.path.split(__file__)[0]
        tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'localtime'))
        self.assertEqual(tz.zone, 'local')
        dt = datetime(2012, 1, 1, 5)
        self.assertEqual(pytz.timezone('Africa/Harare').localize(dt), tz.localize(dt))

if sys.platform == 'win32':

    import tzlocal.win32
    class TzWin32Tests(unittest.TestCase):

        def test_win32(self):
            tzlocal.win32.get_localzone()

if __name__ == '__main__':
    unittest.main()