Skip to content

Commit

Permalink
Merge pull request #17 from idjaw/issue_15
Browse files Browse the repository at this point in the history
Supports multiple Python versions in tox
  • Loading branch information
idjaw authored Feb 12, 2024
2 parents 68c5cc7 + 2a0486f commit bc9eb38
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 37 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ on:
jobs:
test:
runs-on: ${{ matrix.os }}
env:
ACTIONS_STEP_DEBUG: true
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11"]
os: [ubuntu-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
permissions:
contents: write
steps:
Expand All @@ -35,10 +37,18 @@ jobs:
run: |
poetry install
- name: Get Python version for tox
run: |
stripped_py_version=$(echo "${{ matrix.python-version }}" | tr -d '.')
echo "py_version=$stripped_py_version" >> $GITHUB_ENV
id: py_version

- name: Run tests
env:
SKIP_LOAD_TEST: "true"
run: poetry run tox
run: |
poetry run tox -e py${{ env.py_version }}
build:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

## 0.2.1

* Supports tox running multiple Python versions: 3.9, 3.10, 3.11, 3.12 [#15](https://github.com/idjaw/edunet/issues/15)
* CI will now run against 3.9, 3.10, 3.11, 3.12 versions of Python [#15](https://github.com/idjaw/edunet/issues/15)
* REMOVED - Windows in the CI For now. Will address in [#16](https://github.com/idjaw/edunet/issues/16) [#15](https://github.com/idjaw/edunet/issues/15)

## 0.2.0

* Will now better handle building and deploying in the CI [#7](https://github.com/idjaw/edunet/issues/7)
Expand Down
81 changes: 71 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "edunet"
version = "0.2.0"
version = "0.2.1"
description = "Simple Network Simulation For The Funs!"
authors = ["Wajdi Al-Hawari <[email protected]>"]
readme = "README.md"
Expand All @@ -20,6 +20,7 @@ flake8 = "^7.0.0"
pylint = "^3.0.3"
tox = "^4.12.1"
hypothesis = "^6.92.9"
setuptools = "^69.1.0"

[build-system]
requires = ["poetry-core"]
Expand Down
20 changes: 15 additions & 5 deletions tests/unit/core/applications/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ def test_connection_handler_raises_when_methods_not_implemented():
class MyTestApplication(Application):
pass

with pytest.raises(
TypeError,
match="Can't instantiate abstract class MyTestApplication "
"with abstract method handle_request",
):
"""
Please note: Python 3.12 seems to have changed the assertion message being raised so
previous versions are using one set of wording, and Python 3.12 another.
Tests will match on a substring instead
E AssertionError: Regex pattern did not match.
E Regex: "Can't instantiate abstract class MyTestApplication with abstract methods
start, stop"
E Input: "Can't instantiate abstract class MyTestApplication without an implementation
for abstract methods 'start', 'stop'"
"""
with pytest.raises(TypeError) as exc:
MyTestApplication().handle_request("foo") # type: ignore

assert "handle_request" in str(exc.value)
20 changes: 15 additions & 5 deletions tests/unit/core/networking/handlers/test_connection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ def test_connection_handler_raises_when_methods_not_implemented():
class MyTestConnectionHandler(ConnectionHandler):
pass

with pytest.raises(
TypeError,
match="Can't instantiate abstract class MyTestConnectionHandler "
"with abstract method handle_connection",
):
"""
Please note: Python 3.12 seems to have changed the assertion message being raised so
previous versions are using one set of wording, and Python 3.12 another.
Tests will match on a substring instead
E AssertionError: Regex pattern did not match.
E Regex: "Can't instantiate abstract class MyTestConnectionHandler with abstract method
handle_connection"
E Input: "Can't instantiate abstract class MyTestConnectionHandler without an implementation
for abstract method 'handle_connection'"
"""
with pytest.raises(TypeError) as exc:
MyTestConnectionHandler().handle_connection()

assert "handle_connection" in str(exc.value)
20 changes: 15 additions & 5 deletions tests/unit/core/networking/listeners/test_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ def test_listener_raises_when_methods_not_implemented():
class MyTestListener(Listener):
pass

with pytest.raises(
TypeError,
match="Can't instantiate abstract class MyTestListener with abstract methods"
" accept_connection, handle_request, start, stop",
):
"""
Please note: Python 3.12 seems to have changed the assertion message being raised so
previous versions are using one set of wording, and Python 3.12 another.
Tests will match on a substring instead
E AssertionError: Regex pattern did not match.
E Regex: "Can't instantiate abstract class MyTestListener with abstract methods
start, stop"
E Input: "Can't instantiate abstract class MyTestListener without an implementation
for abstract methods 'handle_request', 'start', 'stop'"
"""
with pytest.raises(TypeError) as exc:
MyTestListener().start()

assert all(s in str(exc.value) for s in ["handle_request", "start", "stop"])
2 changes: 1 addition & 1 deletion tests/unit/core/networking/listeners/test_tcp_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_tcp_listener_stop_success(mock_connection_handler, mock_socket, caplog)
tcp_listener.stop()

assert tcp_listener.is_listening is False
assert mock_socket_instance.close.called_once
assert mock_socket_instance.close.call_count == 1
assert "Stopping service" in caplog.text
assert "All threads terminated. Service has been stopped." in caplog.text

Expand Down
21 changes: 16 additions & 5 deletions tests/unit/core/nodes/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ def test_node_raises_when_methods_not_implemented():
class MyNode(Node):
pass

with pytest.raises(
TypeError,
match="Can't instantiate abstract class MyNode "
"with abstract methods start, stop",
):
"""
Please note: Python 3.12 seems to have changed the assertion message being raised so
previous versions are using one set of wording, and Python 3.12 another.
Tests will match on a substring instead
E AssertionError: Regex pattern did not match.
E Regex: "Can't instantiate abstract class MyNode with abstract methods
start, stop"
E Input: "Can't instantiate abstract class MyNode without an implementation
for abstract methods 'start', 'stop'"
"""

with pytest.raises(TypeError) as exc:
MyNode(Mock(spec=Listener)).start("foo") # type: ignore

assert all(s in str(exc.value) for s in ["start", "stop"])
Loading

0 comments on commit bc9eb38

Please sign in to comment.