diff --git a/auto_dev/commands/test.py b/auto_dev/commands/test.py index 41af58e5..58f17d4f 100644 --- a/auto_dev/commands/test.py +++ b/auto_dev/commands/test.py @@ -99,6 +99,8 @@ def test(ctx, path, watch, coverage_report) -> None: """ verbose = ctx.obj["VERBOSE"] + + num_processes = int(ctx.obj["NUM_PROCESSES"]) click.echo( f"Testing path: `{path or 'All dev packages/packages.json'}` ⌛", ) @@ -117,7 +119,7 @@ def test(ctx, path, watch, coverage_report) -> None: results = {} for package in range(len(packages)): click.echo(f"Testing {packages[package]} {package + 1}/{len(packages)}") - result = test_path(str(packages[package]), verbose=verbose, watch=watch, multiple=True) + result = test_path(str(packages[package]), verbose=verbose, watch=watch, multiple=True if num_processes != 1 else False) results[packages[package]] = result click.echo(f"{'👌' if result else '❗'} - {packages[package]}") diff --git a/auto_dev/data/templates/protocols/test_dialogues.jinja b/auto_dev/data/templates/protocols/test_dialogues.jinja index cba0ee88..1360221b 100644 --- a/auto_dev/data/templates/protocols/test_dialogues.jinja +++ b/auto_dev/data/templates/protocols/test_dialogues.jinja @@ -5,7 +5,7 @@ from unittest.mock import MagicMock from pydantic import BaseModel -from hypothesis import given, settings +from hypothesis import given, settings, HealthCheck from hypothesis import strategies as st from aea.configurations.data_types import PublicId @@ -51,7 +51,7 @@ def validate_dialogue(performative, model): {%- for initial_performative in initial_performatives %} -@settings(deadline=1000) +@settings(deadline=1000,suppress_health_check=[HealthCheck.too_slow]) @given(st.from_type({{ snake_to_camel(initial_performative) }})) def test_{{ initial_performative }}_dialogues(model): """Test for the '{{ initial_performative|upper }}' protocol.""" diff --git a/auto_dev/data/templates/protocols/test_messages.jinja b/auto_dev/data/templates/protocols/test_messages.jinja index 344850ce..adf78389 100644 --- a/auto_dev/data/templates/protocols/test_messages.jinja +++ b/auto_dev/data/templates/protocols/test_messages.jinja @@ -5,7 +5,7 @@ import pytest from pydantic import BaseModel from hypothesis import strategies as st -from hypothesis import given +from hypothesis import given, settings, HealthCheck from aea.common import Address from aea.mail.base import Envelope @@ -64,6 +64,7 @@ def perform_message_test(performative, model) -> None: {%- for performative in performative_types %} +@settings(deadline=1000,suppress_health_check=[HealthCheck.too_slow]) @given(st.from_type({{ snake_to_camel(performative) }})) def test_{{ performative }}_messages(model): """Test for the '{{ performative|upper }}' protocol message encode and decode.""" diff --git a/auto_dev/test.py b/auto_dev/test.py index 214874d6..9de0dd0e 100644 --- a/auto_dev/test.py +++ b/auto_dev/test.py @@ -1,8 +1,11 @@ """Module for testing the project.""" +import sys import os from pathlib import Path from multiprocessing import cpu_count +from importlib import invalidate_caches + import pytest @@ -20,7 +23,7 @@ def get_test_cpu_count() -> str: def test_path( - path: str, + path: str | list[str], verbose: bool = False, watch: bool = False, multiple: bool = False, @@ -53,7 +56,10 @@ def test_path( - Integrates with coverage reporting """ - extra_args = ["--cache-clear"] + extra_args = ["--cache-clear", + "--disable-warnings", + "--import-mode=importlib" + ] if verbose: extra_args.append("-v") @@ -65,7 +71,8 @@ def test_path( extra_args.extend(("-n", get_test_cpu_count())) args = [path, *extra_args] - os.environ["PYTHONPATH"] = "." os.environ["PYTHONWARNINGS"] = "ignore" + sys.path.insert(0, os.getcwd()) + print(f"Running tests with pytest args: {args}") result = pytest.main(args) return result == 0