Skip to content

Commit

Permalink
clarify dev dependencies, skip windows incompatible tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ariebovenberg committed Feb 2, 2024
1 parent 29d2cd3 commit ea5ead5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
39 changes: 34 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,44 @@ This project is inspired by the following projects. Check them out!
Contributing
------------

Contributions are welcome! Please open an issue or pull request.
Contributions are welcome! Please open an issue or a pull request.

An example of setting up things and running the tests:
⚠️ **Note**: big changes should be discussed in an issue first.
This is to avoid wasted effort if the change isn't a good fit for the project.

..
⚠️ **Note**: Some tests are skipped on Windows.
These tests use unix-specific features to set the timezone for the current process.
As a result, you won't get 100% coverage on Windows, or be able to run
certain tests that rely on the system timezone.
It can be made to work on Windows too, but I haven't gotten around to it yet.

Setting up a development environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You'll need `poetry <https://python-poetry.org/>`_ installed.
An example of setting up things up:

.. code-block:: bash
poetry install
# To run the tests with the current Python version
pytest
⚠️ **Note**: The tests don't run on Windows yet. This is because
the tests use unix-specific features to set the timezone for the current process.
It can be made to work on Windows too, but I haven't gotten around to it yet.
# if you want to build the docs
pip install -r docs/requirements.txt
# Various checks
mypy src/ tests/
flake8 src/ tests/
# autoformatting
black src/ tests/
isort src/ tests/
# To run the tests with all supported Python versions
# Alternatively, let the github actions on the PR do it for you
pip install tox
tox -p auto
8 changes: 8 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from time import tzset
from unittest.mock import patch

import pytest

__all__ = [
"ZoneInfo",
"ZoneInfoNotFoundError",
Expand All @@ -13,6 +15,8 @@
"AlwaysSmaller",
]

IS_WINDOWS = sys.platform == "win32"


if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
Expand Down Expand Up @@ -60,13 +64,17 @@ def __ge__(self, other):

@contextmanager
def local_ams_tz():
if IS_WINDOWS:
pytest.skip("tzset is not available on Windows")
with patch.dict(os.environ, {"TZ": "Europe/Amsterdam"}):
tzset()
yield


@contextmanager
def local_nyc_tz():
if IS_WINDOWS:
pytest.skip("tzset is not available on Windows")
with patch.dict(os.environ, {"TZ": "America/New_York"}):
tzset()
yield

0 comments on commit ea5ead5

Please sign in to comment.