Skip to content

Commit

Permalink
Add Python 3.12 testing (#1348)
Browse files Browse the repository at this point in the history
* Add Python 3.12 testing
* Update pytest
* Replace deprecated datetime.utcnow()
  • Loading branch information
Shrews committed Mar 19, 2024
1 parent d2afb91 commit 764790f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ jobs:
- name: '3.11'
tox_env: integration-py311

- name: '3.12'
tox_env: integration-py312

steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -124,6 +127,9 @@ jobs:
- name: '3.11'
tox_env: unit-py311

- name: '3.12'
tox_env: unit-py312

steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3 :: Only
Topic :: Software Development :: Libraries :: Python Modules
Topic :: System :: Systems Administration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@


def current_time():
return datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
return datetime.datetime.now(datetime.timezone.utc)


# use a custom JSON serializer so we can properly handle !unsafe and !vault
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def event_callback(self, event_data):

# prefer 'created' from partial data, but verbose events set time here
if 'created' not in event_data:
event_data['created'] = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).isoformat()
event_data['created'] = datetime.datetime.now(datetime.timezone.utc).isoformat()

if self.event_handler is not None:
should_write = self.event_handler(event_data)
Expand Down
2 changes: 1 addition & 1 deletion test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mypy==1.6.0
pylint==3.0.1
pytest==7.1.2
pytest==8.1.1
pytest-cov
pytest-mock
pytest-timeout
Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ deps = ansible27: ansible<2.8
ansible29: ansible<2.10
ansible-base: ansible-base
py{,3,39,310,311}: ansible-core
integration{,-py39,-py310,-py311}: ansible-core
build
-r {toxinidir}/test/requirements.txt
integration{,-py39,-py310,-py311,-py312}: ansible-core
build
-r {toxinidir}/test/requirements.txt
passenv =
HOME
RUNNER_TEST_IMAGE_NAME
usedevelop = True
commands = pytest -vv -n auto {posargs}

[testenv:linters{,-py39,-py310,-py311}]
[testenv:linters{,-py39,-py310,-py311,-py312}]
description = Run code linters
commands =
flake8 --version
Expand All @@ -33,11 +33,11 @@ commands =
mypy src/ansible_runner
pylint src/ansible_runner test

[testenv:unit{,-py39,-py310,-py311}]
[testenv:unit{,-py39,-py310,-py311,-py312}]
description = Run unit tests
commands = pytest -vv -n auto {posargs:test/unit} {[shared]pytest_cov_args}

[testenv:integration{,-py39,-py310,-py311}]
[testenv:integration{,-py39,-py310,-py311,-py312}]
description = Run integration tests
commands = pytest -vv -n auto {posargs:test/integration} {[shared]pytest_cov_args}

Expand Down

0 comments on commit 764790f

Please sign in to comment.