Files
galaxy/test/functional/test_toolbox_pytest.py
T
Nicola Soranzo 7f89e0eab9 Code cleanups from pyupgrade
Found by running:

```
make pyupgrade
ruff check --fix .
ruff check --preview --unsafe-fixes --select=F401 --fix .
make format
make update-client-api-schema
```

The bulk of the changes are replacements of typing deprecated aliases
such as `Dict` and `List` with the standard library classes. These
aliases became redundant in Python 3.9 when the corresponding
pre-existing classes were enhanced to support `[]`, see
https://docs.python.org/3/library/typing.html#deprecated-aliases

Also:
- Update the `pyupgrade` Makefile target to use `--py38-plus` for the
  packages needed by Pulsar, including the new galaxy-tool-util-models
  package.
2025-07-31 11:17:22 +01:00

64 lines
1.8 KiB
Python

import os
from typing import (
NamedTuple,
)
import pytest
from galaxy_test.api._framework import ApiTestCase
from galaxy_test.driver.driver_util import GalaxyTestDriver
SKIPTEST = os.path.join(os.path.dirname(__file__), "known_broken_tools.txt")
class ToolTest(NamedTuple):
tool_id: str
tool_version: str
test_index: int
def get_skiplist():
with open(SKIPTEST) as skiptest:
skiplist = [line.strip() for line in skiptest if line.strip() and not line.startswith("#")]
return skiplist
def get_cases() -> list[ToolTest]:
atc = ApiTestCase()
atc._test_driver = GalaxyTestDriver()
atc._test_driver.setup()
atc.setUp()
test_summary = atc.galaxy_interactor.get_tests_summary()
test_cases = []
for tool_id, summary_dict in test_summary.items():
for tool_version, tool_dict in summary_dict.items():
for index in range(tool_dict["count"]):
test_cases.append(ToolTest(tool_id, tool_version, index))
atc._test_driver.stop_servers()
return test_cases
def cases():
skiplist = get_skiplist()
for tool_test in get_cases():
marks = []
marks.append(pytest.mark.skipif(tool_test.tool_id in skiplist, reason="tool in skiplist"))
if "data_manager_" in tool_test.tool_id:
marks.append(pytest.mark.data_manager(tool_test))
else:
marks.append(pytest.mark.tool(tool_test))
yield pytest.param(tool_test, marks=marks)
def idfn(val: ToolTest):
return f"{val.tool_id}/{val.tool_version}-{val.test_index}"
class TestFrameworkTools(ApiTestCase):
conda_auto_init = True
conda_auto_install = True
@pytest.mark.parametrize("testcase", cases(), ids=idfn)
def test_tool(self, testcase: ToolTest):
self._test_driver.run_tool_test(testcase.tool_id, testcase.test_index, tool_version=testcase.tool_version)