MCPcopy Create free account
hub / github.com/dateutil/dateutil / tz_source_skip_reason

Function tz_source_skip_reason

tests/_common.py:68–94  ·  view source on GitHub ↗

Why tests can't run against ``source`` here, or None if they can. ``"tzpath"`` is the time zone data on TZPATH (the system data, or whatever PYTHONTZPATH points at) with the tzdata package blocked, so that a key that is missing or broken there fails rather than being answered by tzd

(source)

Source from the content-addressed store, hash-verified

66
67
68def tz_source_skip_reason(source):
69 """Why tests can't run against ``source`` here, or None if they can.
70
71 ``"tzpath"`` is the time zone data on TZPATH (the system data, or whatever
72 PYTHONTZPATH points at) with the tzdata package blocked, so that a key
73 that is missing or broken there fails rather than being answered by
74 tzdata. ``"tzdata"`` is the tzdata package, with an empty TZPATH.
75 """
76 if source == "tzpath":
77 # Any real installation of the data has one of these (depending on
78 # whether the "backward" links were installed); anything else, like
79 # an empty directory, is treated as no data at all.
80 if not any(
81 os.path.isfile(os.path.join(path, *key.split("/")))
82 for path in tz.TZPATH
83 for key in ("Etc/UTC", "UTC")
84 ):
85 return "No time zone data on TZPATH"
86 elif source == "tzdata":
87 try:
88 import tzdata # noqa: F401
89 except ImportError:
90 return "tzdata is not installed"
91 else: # pragma: nocover
92 raise ValueError("Unknown time zone data source: %r" % (source,))
93
94 return None
95
96
97def tz_source_context(source):

Callers 2

setUpMethod · 0.85
tz_sourceFunction · 0.85

Calls 1

splitMethod · 0.80

Tested by 1

tz_sourceFunction · 0.68