Skip to content

Commit

Permalink
Re-enable correctly py27 testing and document it
Browse files Browse the repository at this point in the history
rel #93.
  • Loading branch information
kiorky committed Oct 24, 2024
1 parent 17bec1d commit eda0770
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
name: croniter
on: [workflow_dispatch, push, pull_request]
jobs:
build:
build-py2:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["2.7"]
steps:
- uses: actions/checkout@v3
- name: install dependencies && test on py27
run: |
set -ex
sudo apt update && sudo apt install -y python2.7
# install py 2 with eg: apt install python2.7
mkdir venv2 && curl -sSL "https://github.com/pypa/get-virtualenv/blob/20.27.0/public/2.7/virtualenv.pyz?raw=true" > venv2/venv && python2.7 venv2/venv venv2
venv2/bin/python2 -m pip install -r ./requirements/test.txt
venv2/bin/tox --direct -e "py${pyver//\.}-{std,coverage}"
build-py3:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
Expand All @@ -12,15 +30,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: install dependencies && test on py3
run: |
set -ex
python -m pip install --upgrade --use-pep517 pip
pip install --use-pep517 -r requirements/test.txt
- name: Test with pytest
run: |
pyver=$(python --version 2>&1 | awk '{print substr($2, 0, 4)}' | awk '{ sub(/[ \t]+$/, ""); print }');
case $pyver in
2.7) tox -e "py${pyver//\.}-{std,coverage}";;
*) tox -e "py${pyver//\.}-std";;
esac
pyver=$(python --version 2>&1 | awk '{print substr($2, 0, 4)}' | awk '{ sub(/[ \t]+$/, ""); print }')
tox --direct -e "py${pyver//\.}-{std,coverage}"
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
------------------

- Fix overflow on 32bits systems (#87) [kiorky]
- Fix python2 testing (related to #93) [kiorky]

3.0.3 (2024-07-26)
------------------
Expand Down
14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,20 @@ Develop this package
py.test src


Testing under py2
==================

Install prerequisisites ::

# install py 2 with eg: apt install python2.7
mkdir venv2 && curl -sSL "https://github.com/pypa/get-virtualenv/blob/20.27.0/public/2.7/virtualenv.pyz?raw=true" > venv2/venv && python2 venv2/venv venv2
venv2/bin/python2 -m pip install -r ./requirements/test.txt

Run tests::

./venv2/bin/tox --direct -e py27-std


Make a new release
====================
We use zest.fullreleaser, a great release infrastructure.
Expand Down
5 changes: 4 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
-r base.txt
pytz
pytest>=3.0.3
tox>=2.4.1
coverage>=4.2
mock>=2.0.0 # For Python 2
coveralls
flake8
tzlocal
pylint
pylama
tox-direct
setuptools
7 changes: 6 additions & 1 deletion src/croniter/croniter.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ def is_32bit():
# retrocompat
VALID_LEN_EXPRESSION = set([a for a in CRON_FIELDS if isinstance(a, int)])
EXPRESSIONS = {}
try:
# py3 recent
UTC_DT = datetime.timezone.utc
except AttributeError:
UTC_DT = pytz.utc


def timedelta_to_seconds(td):
Expand Down Expand Up @@ -1010,7 +1015,7 @@ def expand(cls, expr_format, hash_id=None, second_at_beginning=False, from_times

@classmethod
def _get_low_from_current_date_number(cls, i, step, from_timestamp):
dt = datetime.datetime.fromtimestamp(from_timestamp, tz=datetime.timezone.utc)
dt = datetime.datetime.fromtimestamp(from_timestamp, tz=UTC_DT)
if i == MINUTE_FIELD:
return dt.minute % step
if i == HOUR_FIELD:
Expand Down

1 comment on commit eda0770

@akx
Copy link

@akx akx commented on eda0770 Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the new test requirements? I don't see anything using them.

Please sign in to comment.