Skip to content

Running test_icalendar.py::test_omits_dst_offset fails. #107

@nafanz

Description

@nafanz

Quick Summary
Running test_icalendar.py::test_omits_dst_offset fails.

Context

  • Python 3.12.7
  • PyCharm 2024.3.1 (Community Edition)
  • Ubuntu 24.10

Description
Started from the last commit 2094c7149f120f1b3e0a8ef28b82c004db684810
Running test_icalendar.py::test_omits_dst_offset fails.

Since the problem is probably related to time zones, I will indicate mine.

timedatectl
               Local time: Пт 2025-01-31 19:35:15 +05
           Universal time: Пт 2025-01-31 14:35:15 UTC
                 RTC time: Пт 2025-01-31 14:35:15
                Time zone: Asia/Yekaterinburg (+05, +0500)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

To Reproduce
Run the test test_icalendar.py::test_omits_dst_offset

Further Notes
All tests are successful except one.

============================== 1 failed in 1.63s ===============================
FAILED                          [100%]
tests/test_icalendar.py:546 (test_omits_dst_offset)
key = 'US/Eastern'

    def load_tzdata(key):
        from importlib import resources
    
        components = key.split("/")
        package_name = ".".join(["tzdata.zoneinfo"] + components[:-1])
        resource_name = components[-1]
    
        try:
>           return resources.files(package_name).joinpath(resource_name).open("rb")

/usr/lib/python3.12/zoneinfo/_common.py:12: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.12/importlib/resources/_common.py:46: in wrapper
    return func(anchor)
/usr/lib/python3.12/importlib/resources/_common.py:56: in files
    return from_package(resolve(anchor))
/usr/lib/python3.12/functools.py:907: in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
/usr/lib/python3.12/importlib/resources/_common.py:82: in _
    return importlib.import_module(cand)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'tzdata.zoneinfo.US', package = None

    def import_module(name, package=None):
        """Import a module.
    
        The 'package' argument is required when performing a relative import. It
        specifies the package to use as the anchor point from which to resolve the
        relative import to an absolute import.
    
        """
        level = 0
        if name.startswith('.'):
            if not package:
                raise TypeError("the 'package' argument is required to perform a "
                                f"relative import for {name!r}")
            for character in name:
                if character != '.':
                    break
                level += 1
>       return _bootstrap._gcd_import(name[level:], package, level)
E       ModuleNotFoundError: No module named 'tzdata'

/usr/lib/python3.12/importlib/__init__.py:90: ModuleNotFoundError

During handling of the above exception, another exception occurred:

    def test_omits_dst_offset():
    
        # Check dateutil, pytz, and zoneinfo (3.9+) tzinfo instances
        _timezones = []
        if "dateutil" in globals():
            tz = dateutil.tz.gettz("US/Eastern")
            assert tz is not None
            _timezones.append(tz)
        if "zoneinfo" in globals():
>           tz = zoneinfo.ZoneInfo("US/Eastern")

test_icalendar.py:556: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

key = 'US/Eastern'

    def load_tzdata(key):
        from importlib import resources
    
        components = key.split("/")
        package_name = ".".join(["tzdata.zoneinfo"] + components[:-1])
        resource_name = components[-1]
    
        try:
            return resources.files(package_name).joinpath(resource_name).open("rb")
        except (ImportError, FileNotFoundError, UnicodeEncodeError):
            # There are three types of exception that can be raised that all amount
            # to "we cannot find this key":
            #
            # ImportError: If package_name doesn't exist (e.g. if tzdata is not
            #   installed, or if there's an error in the folder name like
            #   Amrica/New_York)
            # FileNotFoundError: If resource_name doesn't exist in the package
            #   (e.g. Europe/Krasnoy)
            # UnicodeEncodeError: If package_name or resource_name are not UTF-8,
            #   such as keys containing a surrogate character.
>           raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
E           zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key US/Eastern'

/usr/lib/python3.12/zoneinfo/_common.py:24: ZoneInfoNotFoundError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions