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)
| 66 | |
| 67 | |
| 68 | def 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 | |
| 97 | def tz_source_context(source): |