diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ffa69bc..a57fd52 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,8 +1,14 @@ name: Tests on: + push: + branches: [ master, main ] + paths: + - 'src/datadreamer/**/**.py' + - 'tests/**/**.py' + - .github/workflows/tests.yaml pull_request: - branches: [ dev, main, add-tests ] + branches: [ dev, main ] paths: - 'src/datadreamer/**/**.py' - 'tests/**/**.py' @@ -36,14 +42,19 @@ jobs: sudo apt update sudo apt install -y pandoc pip install -e .[dev] + pip install pytest coverage-badge - name: Install dependencies [Windows] if: matrix.os == 'windows-latest' - run: pip install -e .[dev] + run: | + pip install -e .[dev] + pip install pytest coverage-badge - name: Install dependencies [macOS] if: matrix.os == 'macOS-latest' - run: pip install -e .[dev] + run: | + pip install -e .[dev] + pip install pytest coverage-badge - name: Run tests with coverage [Ubuntu] if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' diff --git a/tests/unittests/test_annotators.py b/tests/unittests/test_annotators.py index 73f0d8b..4be509f 100644 --- a/tests/unittests/test_annotators.py +++ b/tests/unittests/test_annotators.py @@ -4,7 +4,8 @@ def test_owlv2_annotator(): device = "cuda" if torch.cuda.is_available() else "cpu" - pass + assert device in ["cuda", "cpu"] + if __name__ == "__main__": diff --git a/tests/unittests/test_image_generation.py b/tests/unittests/test_image_generation.py index a015533..09e9879 100644 --- a/tests/unittests/test_image_generation.py +++ b/tests/unittests/test_image_generation.py @@ -1,5 +1,6 @@ import pytest import torch +from PIL import Image from datadreamer.image_generation.sdxl_image_generator import StableDiffusionImageGenerator from datadreamer.image_generation.sdxl_turbo_image_generator import StableDiffusionTurboImageGenerator from datadreamer.image_generation.clip_image_tester import ClipImageTester @@ -7,14 +8,16 @@ def test_clip_image_tester(): device = "cuda" if torch.cuda.is_available() else "cpu" - pass + assert device in ["cuda", "cpu"] def test_sdxl_image_generator(): device = "cuda" if torch.cuda.is_available() else "cpu" # image_generator = StableDiffusionImageGenerator(device=device) image_generator = StableDiffusionImageGenerator() - generated_image = image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]]) + for generated_image in image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]]): + assert generated_image is not None + assert isinstance(generated_image, Image.Image) image_generator.release(empty_cuda_cache=True if device != 'cpu' else False) @@ -22,7 +25,9 @@ def test_sdxl_turbo_image_generator(): device = "cuda" if torch.cuda.is_available() else "cpu" # image_generator = StableDiffusionTurboImageGenerator(device=device) image_generator = StableDiffusionTurboImageGenerator() - generated_image = image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]]) + for generated_image in image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]]): + assert generated_image is not None + assert isinstance(generated_image, Image.Image) image_generator.release(empty_cuda_cache=True if device != 'cpu' else False)