From a4b20ae101d5792ebf7ed90560202cee7f25b25b Mon Sep 17 00:00:00 2001 From: Naglis Jonaitis Date: Mon, 8 Apr 2024 12:49:05 +0300 Subject: [PATCH] Avoid DUMMY_CONVERSION env var treated as bool in CI `DUMMY_CONVERSION: True` is treated as a boolean value in YAML[1]. As a result, during GitHub CI the environment variable setup during tests is formatted as `DUMMY_CONVERSION=true`. The value is used[2] in tests and passed as the `condition` to the `pytest.mark.skipif`[3] decorator. The `skipif` `condition` can be either a `bool` or `str`. When it is a `str` (our case, as we use `os.environ.get()`), it is treated as a condition string[4] by pytest. Since the condition string is `eval()`ed[5] by pytest, trying to evaluate `true` results in: > Failed: Error evaluating 'skipif' condition > true > NameError: name 'true' is not defined To avoid the implicit conversion to a JSON boolean, or marking the "True" value as a string literal, use the value `1` instead. [1]: https://yaml.org/type/bool.html [2]: https://github.com/freedomofpress/dangerzone/blob/9bb1993e7768f721ab2260b407c58ec8dbb5f29c/tests/isolation_provider/base.py#L25 [3]: https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif-ref [4]: https://docs.pytest.org/en/stable/historical-notes.html#string-conditions [5]: https://github.com/pytest-dev/pytest/blob/f75dd87eb7f31c4d14c84c18ce97353f51e801d4/src/_pytest/skipping.py#L117 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 914c942..469b944 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: windows: runs-on: windows-latest env: - DUMMY_CONVERSION: True + DUMMY_CONVERSION: 1 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -31,7 +31,7 @@ jobs: macOS: runs-on: macos-latest env: - DUMMY_CONVERSION: True + DUMMY_CONVERSION: 1 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4