Add tox configuration, we support 3.10 & 3.11 (#22)

This commit is contained in:
thomas
2023-03-23 12:38:58 +00:00
committed by GitHub
parent 6b218a3926
commit d602ddf3bf
5 changed files with 25 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
name: Run pytest name: Tests
on: on:
pull_request: pull_request:
@@ -9,14 +9,23 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.10']
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install pytest pip install tox
- name: Run pytest - name: Run tox
run: pytest run: tox

View File

@@ -54,6 +54,8 @@ Install via the extensions tab on the [AUTOMATIC1111 webui](https://github.com/A
Developed using existing [AUTOMATIC1111 webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) dependencies. Developed using existing [AUTOMATIC1111 webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) dependencies.
It's recommended to use the python version specified by A111 webui.
However - for running unit tests, we use pytest. However - for running unit tests, we use pytest.
```bash ```bash

View File

@@ -1,6 +1,7 @@
from abc import ABC from abc import ABC
from abc import abstractmethod from abc import abstractmethod
from functools import partial from functools import partial
from typing import Callable
import gradio as gr import gradio as gr
@@ -190,7 +191,7 @@ class PredefinedAspectRatioButtons(ArhUIComponent):
) )
@property @property
def display_func(self) -> callable: def display_func(self) -> Callable[[str], str]:
return lambda _: None # todo: different displays for aspect ratios. return lambda _: None # todo: different displays for aspect ratios.
@@ -268,7 +269,7 @@ class PredefinedPercentageButtons(ArhUIComponent):
) )
@property @property
def display_func(self) -> callable: def display_func(self) -> Callable[[str], str]:
return _settings.PREDEFINED_PERCENTAGES_DISPLAY_MAP.get( return _settings.PREDEFINED_PERCENTAGES_DISPLAY_MAP.get(
_settings.safe_opt( _settings.safe_opt(
_constants.ARH_PREDEFINED_PERCENTAGES_DISPLAY_KEY, _constants.ARH_PREDEFINED_PERCENTAGES_DISPLAY_KEY,

View File

@@ -3,7 +3,7 @@ import contextlib
import aspect_ratio_helper._constants as _const import aspect_ratio_helper._constants as _const
def safe_opt_util(shared_opts, key, default_key_map): def safe_opt_util(shared_opts, key, default_key_map: dict[str, object]):
# attempt to retrieve key from shared options # attempt to retrieve key from shared options
with contextlib.suppress(AttributeError): with contextlib.suppress(AttributeError):
value = shared_opts.__getattr__(key) value = shared_opts.__getattr__(key)

6
tox.ini Normal file
View File

@@ -0,0 +1,6 @@
[tox]
envlist = py310, py311
[testenv]
deps = pytest
commands = pytest