Files
galaxy/lib/galaxy_test/api/_framework.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

43 lines
1.2 KiB
Python

from collections.abc import Iterator
from typing import (
Optional,
)
from unittest import SkipTest
import pytest
from galaxy_test.base.api import (
UsesApiTestCaseMixin,
UsesCeleryTasks,
)
from galaxy_test.base.testcase import FunctionalTestCase
try:
from galaxy_test.driver.driver_util import GalaxyTestDriver
except ImportError:
# Galaxy libraries and galaxy test driver not available, just assume we're
# targetting a remote Galaxy.
GalaxyTestDriver = None # type: ignore[assignment, misc, unused-ignore]
class ApiTestCase(FunctionalTestCase, UsesApiTestCaseMixin, UsesCeleryTasks):
galaxy_driver_class = GalaxyTestDriver
_test_driver: Optional[GalaxyTestDriver]
def setUp(self):
super().setUp()
self._setup_interactor()
def driver_or_skip_test_if_remote(self) -> GalaxyTestDriver:
if self._test_driver is None:
raise SkipTest("This test does not work with remote Galaxy instances.")
return self._test_driver
@pytest.fixture
def history_id(self) -> Iterator[str]:
with self.galaxy_interactor.test_history() as history_id:
yield history_id
__all__ = ("ApiTestCase",)