Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make test timezone aware #543

Merged
merged 10 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux-build-test-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-build-test-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-test-with-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04"]
runs-on: ${{ matrix.runs-on }}
steps:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/osx-build-test-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-14, macos-12]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: ["macos-12", "macos-13", "macos-14", "macos-15"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

exclude:
- os: "macos-12"
python-version: "3.13"

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/osx-test-with-brew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ jobs:
osx_wheel:
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
runs-on: [ "macos-14", "macos-12" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
runs-on: ["macos-12", "macos-13", "macos-14", "macos-15"]
exclude:
- os: "macos-12"
python-version: "3.13"

runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
needs: publish-to-testpypi
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04, macos-14, macos-12, windows-2022, windows-2019]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-24.04"," ubuntu-22.04", "ubuntu-20.04", "macos-12", "macos-13", "macos-14", "macos-15", "windows-2019", "windows-2022"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ jobs:
needs: publish-to-testpypi
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04, macos-14, macos-12, windows-2022, windows-2019]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-24.04"," ubuntu-22.04", "ubuntu-20.04", "macos-12", "macos-13", "macos-14", "macos-15", "windows-2019", "windows-2022"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-build-test-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
matrix:
os: [windows-2022, windows-2019]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
runs-on: [ "windows-2022", "windows-2019" ]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout
Expand Down
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
- id: check-shebang-scripts-are-executable
- id: check-json
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: check-yaml
- id: check-illegal-windows-names
- id: check-merge-conflict
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key
- id: forbid-submodules
- id: mixed-line-ending

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.10.0'
rev: 'v1.13.0'
hooks:
- id: mypy
additional_dependencies: [types-setuptools, types-click]
files: ^snap7

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.2'
rev: 'v0.7.2'
hooks:
- id: ruff
- id: ruff-format
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "python-snap7"
version = "2.0.0"
version = "2.0.1"
description = "Python wrapper for the snap7 library"
readme = "README.rst"
authors = [
Expand All @@ -22,6 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
license = {text = "MIT License"}
requires-python = ">=3.9"
Expand All @@ -32,7 +33,7 @@ Homepage = "https://github.com/gijzelaerr/python-snap7"
Documentation = "https://python-snap7.readthedocs.io/en/latest/"

[project.optional-dependencies]
test = ["pytest", "mypy", "types-setuptools", "ruff", "tox", "types-click"]
test = ["pytest", "mypy", "types-setuptools", "ruff", "tox", "types-click", "uv"]
cli = ["rich", "click" ]
doc = ["sphinx", "sphinx_rtd_theme", "enum-tools[sphinx]"]

Expand Down
38 changes: 17 additions & 21 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# 'tox -e requirements-dev'
#

alabaster==1.0.0
# This file was autogenerated by uv via the following command:
# uv pip compile --extra test --extra cli --extra doc --output-file=requirements-dev.txt pyproject.toml
alabaster==0.7.16
# via sphinx
apeye==1.4.1
# via sphinx-toolbox
Expand All @@ -17,14 +12,12 @@ babel==2.16.0
# via sphinx
beautifulsoup4==4.12.3
# via sphinx-toolbox
cachecontrol[filecache]==0.14.0
cachecontrol==0.14.0
# via sphinx-toolbox
cachetools==5.5.0
# via tox
certifi==2024.8.30
# via
# requests
# sphinx-prompt
# via requests
chardet==5.2.0
# via tox
charset-normalizer==3.4.0
Expand Down Expand Up @@ -52,7 +45,7 @@ domdf-python-tools==3.9.0
# apeye-core
# dict2css
# sphinx-toolbox
enum-tools[sphinx]==0.12.0
enum-tools==0.12.0
# via python-snap7 (pyproject.toml)
exceptiongroup==1.2.2
# via pytest
Expand All @@ -68,9 +61,10 @@ idna==3.10
# via
# apeye-core
# requests
# sphinx-prompt
imagesize==1.4.1
# via sphinx
importlib-metadata==8.5.0
# via sphinx
iniconfig==2.0.0
# via pytest
jinja2==3.1.4
Expand Down Expand Up @@ -140,24 +134,24 @@ snowballstemmer==2.2.0
# via sphinx
soupsieve==2.6
# via beautifulsoup4
sphinx==8.1.3
sphinx==7.4.7
# via
# python-snap7 (pyproject.toml)
# autodocsumm
# enum-tools
# python-snap7 (pyproject.toml)
# sphinx-autodoc-typehints
# sphinx-prompt
# sphinx-rtd-theme
# sphinx-tabs
# sphinx-toolbox
# sphinxcontrib-jquery
sphinx-autodoc-typehints==2.5.0
sphinx-autodoc-typehints==2.3.0
# via sphinx-toolbox
sphinx-jinja2-compat==0.3.0
# via
# enum-tools
# sphinx-toolbox
sphinx-prompt==1.9.0
sphinx-prompt==1.8.0
# via sphinx-toolbox
sphinx-rtd-theme==3.0.1
# via python-snap7 (pyproject.toml)
Expand Down Expand Up @@ -203,10 +197,12 @@ typing-extensions==4.12.2
# sphinx-toolbox
# tox
urllib3==2.2.3
# via
# requests
# sphinx-prompt
# via requests
uv==0.4.29
# via python-snap7 (pyproject.toml)
virtualenv==20.27.1
# via tox
webencodings==0.5.1
# via html5lib
zipp==3.20.2
# via importlib-metadata
12 changes: 9 additions & 3 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
pointer,
Array,
)
from datetime import datetime, timedelta, date
from datetime import datetime, timedelta, timezone
from multiprocessing import Process
from unittest import mock
from typing import cast as typing_cast
Expand Down Expand Up @@ -803,8 +803,14 @@ def test_get_pg_block_info(self) -> None:
self.assertEqual(10, block_info.BlkType)
self.assertEqual(99, block_info.BlkNumber)
self.assertEqual(2752512, block_info.SBBLength)
self.assertEqual(bytes((date(2019, 6, 27).strftime("%Y/%m/%d")), encoding="utf-8"), block_info.CodeDate)
self.assertEqual(bytes((date(2019, 6, 27).strftime("%Y/%m/%d")), encoding="utf-8"), block_info.IntfDate)
self.assertEqual(
bytes((datetime(2019, 6, 27, tzinfo=timezone.utc).astimezone().strftime("%Y/%m/%d")), encoding="utf-8"),
block_info.CodeDate,
)
self.assertEqual(
bytes((datetime(2019, 6, 27, tzinfo=timezone.utc).astimezone().strftime("%Y/%m/%d")), encoding="utf-8"),
block_info.IntfDate,
)

def test_iso_exchange_buffer(self) -> None:
# Cli_IsoExchangeBuffer
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ envlist =
py310
py311
py312
py313
isolated_build = true

[testenv]
Expand Down Expand Up @@ -38,10 +39,9 @@ commands =
ruff check --fix {toxinidir}/snap7 {toxinidir}/tests {toxinidir}/example

[testenv:requirements-dev]
basepython = python3.10
basepython = python3.9
labels = requirements
deps = pip-tools
deps = uv
skip_install = true
setenv = CUSTOM_COMPILE_COMMAND='tox -e requirements-dev'
commands =
pip-compile --upgrade --resolver backtracking --extra test,cli,doc --allow-unsafe pyproject.toml --output-file requirements-dev.txt
commands = uv pip compile --upgrade --extra test --extra cli --extra doc --output-file=requirements-dev.txt pyproject.toml
Loading