Skip to content

Commit

Permalink
Adjust the tests and typing
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Jan 18, 2024
1 parent 912c751 commit 2116757
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ jobs:
FORCE_COLOR: 1

- name: Prepare the snapshot archive
if: always()
if: (success() || failure()) && (runner.os == 'Linux')
# language=bash
run: |
sudo apt-get install lrzip
tar -c * | lrzip -q -z -o snapshot.lrz # To decompress locally, use "lrzuntar snapshot.lrz"
- name: Upload diagnostic snapshot
uses: actions/upload-artifact@v3
if: always()
if: (success() || failure()) && (runner.os == 'Linux')
with:
name: ${{github.job}}
path: snapshot.lrz
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ testpaths = yakut tests
python_files = *.py
python_classes = _UnitTest
python_functions = _unittest_
log_level = DEBUG
log_level = INFO
log_cli_level = WARNING
log_cli = true
log_file = pytest.log
log_file_level = DEBUG
# Unraisable exceptions are filtered because PyTest yields false-positives coming from PyCyphal.
addopts = --doctest-modules -v -p no:unraisableexception
asyncio_mode = auto
Expand Down
7 changes: 4 additions & 3 deletions tests/cmd/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def _unittest_monitor_nodes(compiled_dsdl: Any) -> None:
asyncio.create_task(_delay(_run_nodes(), 1.0, duration=5.0)),
asyncio.create_task(_delay(_run_anonymous(), 1.0, duration=5.0)),
]
cells = [x.split() for x in (await _monitor_and_get_last_screen(15.0, 42)).splitlines()]
cells = [x.split() for x in (await _monitor_and_get_last_screen(20.0, 42)).splitlines()]
await asyncio.gather(*tasks)
await asyncio.sleep(3.0)

Expand Down Expand Up @@ -171,10 +171,10 @@ async def _monitor_and_get_last_screen(duration: float, node_id: Optional[int])
assert "Traceback" not in stderr

screens = stdout.split("\n" * 3)
assert len(screens) > 1
assert len(screens) >= 1
assert len(screens) < (duration * 0.5 + 10)
last_screen = screens[-1]
_logger.info("=== LAST SCREEN ===\n" + last_screen)
_logger.info("=== LAST SCREEN ===\n%s", last_screen)
return last_screen
except Exception: # pragma: no cover
proc.kill()
Expand Down Expand Up @@ -257,6 +257,7 @@ def instantiate(info: NodeInfo, node_id: int, mode: int, health: int, vssc: int)
),
]
pub = nodes[0].make_publisher(String_1, "spam")
pub.send_timeout = 5.0
nodes[1].make_subscriber(String_1, "spam").receive_in_background(subscription_sink)
nodes[2].make_subscriber(String_1, "spam").receive_in_background(subscription_sink)
nodes[3].make_subscriber(String_1, "null").receive_in_background(subscription_sink) # No publishers.
Expand Down
12 changes: 8 additions & 4 deletions yakut/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
# This software is distributed under the terms of the MIT License.
# Author: Pavel Kirienko <[email protected]>

# Disabling unused ignores because we need to support differnt versions of importlib.resources.
# mypy: warn_unused_ignores=False
# pylint: disable=wrong-import-position

import typing


def _read_package_file(name: str) -> str:
try:
from importlib.resources import files
from importlib.resources import files # type: ignore

return (files(__name__) / name).read_text(encoding="utf8")
return (files(__name__) / name).read_text(encoding="utf8") # type: ignore
except ImportError: # This is for the old Pythons; read_text is deprecated in 3.11
from importlib.resources import read_text
from importlib.resources import read_text # type: ignore

return read_text(__name__, name, encoding="utf8")
return read_text(__name__, name, encoding="utf8") # type: ignore


__version__: str = _read_package_file("VERSION").strip()
Expand Down

0 comments on commit 2116757

Please sign in to comment.