diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f13c7c..d348c78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,21 +16,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Install dependencies + - name: Run tests run: | - sudo apt-get update sudo apt-get install -y python3 python3-venv python3-pip - python3 -m pip install --upgrade pip python3 -m venv .venv source .venv/bin/activate - pip install ".[test]" - - - name: Run Pytest - shell: 'script -q -e -c "bash {0}"' # work around tty issues - env: - TERM: linux # fix tput for tty issue work around - run: | - source .venv/bin/activate + python3 -m pip install ".[test]" python3 -m pytest diff --git a/src/khalorg/khal/calendar.py b/src/khalorg/khal/calendar.py index 77397dd..8a363d5 100644 --- a/src/khalorg/khal/calendar.py +++ b/src/khalorg/khal/calendar.py @@ -84,8 +84,8 @@ def __init__(self, name: str): """ path_config: Union[str, None] = find_configuration_file() - new_item_args: list = ['khal', 'new'] - list_args: list = ['khal', 'list', '-df', ''] + new_item_args: list = ["python3", "-m", "khal", "new"] + list_args: list = ["python3", "-m", "khal", "list", "-df", ""] self._collection: CalendarCollection self._new_item: Callable = subprocess_callback(new_item_args) diff --git a/src/khalorg/khal/helpers.py b/src/khalorg/khal/helpers.py index 00ae0a9..d6a616a 100644 --- a/src/khalorg/khal/helpers.py +++ b/src/khalorg/khal/helpers.py @@ -1,4 +1,5 @@ import logging +import sys from datetime import date, datetime from subprocess import STDOUT, CalledProcessError, check_output from typing import Callable @@ -56,6 +57,7 @@ def subprocess_callback(cmd: list) -> Callable: callback function """ + def callback(args: list) -> str: return try_check_output([*cmd, *args]).decode() @@ -64,12 +66,13 @@ def callback(args: list) -> str: def try_check_output(args: list) -> bytes: try: - return check_output(args, stderr=STDOUT) + return check_output(args, stderr=STDOUT, executable=sys.executable) except CalledProcessError as error: error_message: str = ( f"The following arguments were sent to khal:\n\n{' '.join(args)}" "\n\nNext, the following error was received from khal:\n\n" - f"{error.output.decode()}\n\n") + f"{error.output.decode()}\n\n" + ) logging.critical(error_message) raise Exception(error_message) from error