Skip to content

TST: Separate remote and non-remote tests in docs/coordinates/index.rst #14646

Open

Description

@pllim

As @eerovaher stated in #14286 (comment) , "There's two related examples here close to each other. The first example shows how to get the name of a timezone and that can be left as a remote test. The second example demonstrates using a ZoneInfo object created from the timezone name and can be made a non-remote test if tz_name is defined in a setup block."

In docs/coordinates/index.rst:

.. doctest-remote-data::

    >>> loc = EarthLocation.of_address('Tucson, AZ')
    >>> from timezonefinder import TimezoneFinder
    >>> tz_name = TimezoneFinder().timezone_at(lng=loc.lon.degree,
    ...                                        lat=loc.lat.degree)
    >>> tz_name
    'America/Phoenix'

The resulting timezone name could then be used with any packages that support
time zone definitions, such as the (Python 3.9 default package) `zoneinfo
<https://docs.python.org/3/library/zoneinfo.html>`_:

.. doctest-remote-data::

    >>> import datetime
    >>> from zoneinfo import ZoneInfo
    >>> tz = ZoneInfo(tz_name)
    >>> dt = datetime.datetime(2021, 4, 12, 20, 0, 0, tzinfo=tz)

Activity

  1. eerovaher commented on Apr 19, 2023

    @eerovaher
    Member

    The reason this wasn't done already in #14286 was that it lead to some test failures because it seems that the Docker images used for those tests did not have timezone info available. Addressing this issue requires editing Docker configuration, which I don't think is something we should label as good first issue.

  2. pllim commented on Apr 19, 2023

    @pllim
    MemberAuthor

    Ah, I missed the point about Docker. Thanks for the clarification!

  3. eerovaher commented on Apr 19, 2023

    @eerovaher
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions