Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ac1a931
Removed build_machine parameter
eblanco-ansys Sep 29, 2025
c473b0a
Removed skip_space_claim parameter
eblanco-ansys Sep 29, 2025
a119deb
Removed skip_edb parameter
eblanco-ansys Sep 29, 2025
fb7bb2c
Removed skip_debug parameter
eblanco-ansys Sep 29, 2025
4c4fb76
Removed local parameter
eblanco-ansys Sep 29, 2025
2d608a0
Removed skip_desktop_test parameter
eblanco-ansys Sep 29, 2025
e7fd241
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 1, 2025
a4ff090
Refactored conftest to be unified
eblanco-ansys Oct 2, 2025
cf6bfd1
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 2, 2025
6d13be5
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 2, 2025
fa3eb44
Updated conftest docs AEDT version
eblanco-ansys Oct 2, 2025
b996eaf
Merge branch 'refactor/outdated-local-config-parameters' of https://g…
eblanco-ansys Oct 2, 2025
d47ac49
chore: adding changelog file 6727.miscellaneous.md [dependabot-skip]
pyansys-ci-bot Oct 2, 2025
58826ac
chore: adding changelog file 6727.miscellaneous.md [dependabot-skip]
pyansys-ci-bot Oct 2, 2025
6c8ea24
Fixes
eblanco-ansys Oct 6, 2025
710be46
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 6, 2025
686b6e1
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 6, 2025
135d0c9
Fixes
eblanco-ansys Oct 6, 2025
34c41bd
Merge branches 'refactor/outdated-local-config-parameters' and 'refac…
eblanco-ansys Oct 6, 2025
117cb02
Fixes
eblanco-ansys Oct 6, 2025
859a5ea
Refactor test marker assignment to use constants instead of string li…
eblanco-ansys Oct 8, 2025
11a1e9b
Fixed example folders
eblanco-ansys Oct 9, 2025
895c83b
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 9, 2025
84ad71b
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 9, 2025
4abfa07
Test fixes
eblanco-ansys Oct 15, 2025
73f6f09
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 15, 2025
93c57af
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 15, 2025
f562418
Fix tests, ci and refactored to use pathlib
eblanco-ansys Oct 16, 2025
7eb26e4
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 16, 2025
ba731ad
Fixed solver tests
eblanco-ansys Oct 16, 2025
1d45023
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 16, 2025
3894398
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 16, 2025
1e147e3
Fixed test
eblanco-ansys Oct 16, 2025
ed041c6
Fixed test
eblanco-ansys Oct 16, 2025
36d65a6
Added lazy load setting
eblanco-ansys Oct 17, 2025
45dbfb8
Fixed tests
eblanco-ansys Oct 17, 2025
aec7707
Fixed emit tests
eblanco-ansys Oct 17, 2025
21347c2
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 17, 2025
668a13e
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Oct 17, 2025
59dc1f8
FIX: Reverted doc pyaedt_settings.yaml to previous revision
eblanco-ansys Oct 21, 2025
881b1a3
Added PYAEDT_LOCAL_SETTINGS_PATH to env settings
eblanco-ansys Oct 21, 2025
1eaca79
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 21, 2025
53e027f
Fix pytest_arguments
eblanco-ansys Oct 21, 2025
d7f08b8
Fix security issues
eblanco-ansys Oct 21, 2025
70f4994
Patch PYAEDT_LOCAL_SETTINGS_PATH variable to empty string
eblanco-ansys Oct 21, 2025
e0d47ae
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 21, 2025
054dc37
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 24, 2025
d9d9e7f
FIX: Refactor mock_circuit_app fixture for consistency in mocking
eblanco-ansys Oct 27, 2025
0807b82
Merge branch 'main' into refactor/outdated-local-config-parameters
eblanco-ansys Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run unit tests
env:
PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml'
uses: ansys/actions/tests-pytest@c2fa7c93f6883114e0e643599431b33d29f0b13f # v10.1.4
with:
pytest-postargs: 'tests/unit'
Expand Down Expand Up @@ -291,7 +293,7 @@ jobs:
- name: Run tests marked with 'solvers'
env:
PYTHONMALLOC: malloc
PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }}
PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml'
run: |
.venv\Scripts\Activate.ps1
pytest ${PYTEST_ARGUMENTS} --timeout=600 -m solvers
Expand Down Expand Up @@ -365,6 +367,7 @@ jobs:
PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }}
run: |
export LD_LIBRARY_PATH=${ANSYSEM}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
export PYAEDT_LOCAL_SETTINGS_PATH='tests/pyaedt_settings.yaml'
source .venv/bin/activate
pytest ${PYTEST_ARGUMENTS} --timeout=600 -m solvers

Expand Down Expand Up @@ -435,6 +438,7 @@ jobs:
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
env:
PYTHONMALLOC: malloc
PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml'
with:
max_attempts: 2
retry_on: error
Expand Down Expand Up @@ -521,6 +525,7 @@ jobs:
timeout_minutes: 40
command: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT252 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
export PYAEDT_LOCAL_SETTINGS_PATH='tests/pyaedt_settings.yaml'
source .venv/bin/activate
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile --timeout=600 -m general

Expand Down Expand Up @@ -594,6 +599,7 @@ jobs:
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
env:
PYTHONMALLOC: malloc
PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml'
with:
max_attempts: 2
retry_on: error
Expand Down Expand Up @@ -681,6 +687,7 @@ jobs:
timeout_minutes: 40
command: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT252 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
export PYAEDT_LOCAL_SETTINGS_PATH='tests/pyaedt_settings.yaml'
source .venv/bin/activate
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile --timeout=600 -m visualization -x

Expand Down Expand Up @@ -751,6 +758,7 @@ jobs:
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
env:
PYTHONMALLOC: malloc
PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml'
with:
max_attempts: 2
retry_on: error
Expand Down Expand Up @@ -842,6 +850,7 @@ jobs:
timeout_minutes: 120
command: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT252 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
export PYAEDT_LOCAL_SETTINGS_PATH='tests/pyaedt_settings.yaml'
source .venv/bin/activate
xvfb-run pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -m extensions

Expand Down Expand Up @@ -912,6 +921,7 @@ jobs:
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
env:
PYTHONMALLOC: malloc
PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml'
with:
max_attempts: 2
retry_on: error
Expand Down Expand Up @@ -987,6 +997,7 @@ jobs:
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
env:
PYTHONMALLOC: malloc
PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml'
with:
max_attempts: 2
retry_on: error
Expand Down
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,11 @@ dist/
/htmlcov/
/coverage.xml
/tests/system/general/coverage.xml
/tests/system/general/local_config.json
/tests/system/solvers/coverage.xml
/tests/system/solvers/local_config.json
/tests/unit/coverage.xml
test-results.xml
test-output.xml
*local_config.json

# Scratch Jupyter Notebooks
scratch_notebooks/
Expand All @@ -397,13 +396,10 @@ model.index\+

# local environment settings used by e.g. Visual Studio Code
/.env
/doc/source/local_config.json
/.venv*

# test coverage output
/.cov/
/tests/system/visualization/local_config.json
/tests/system/general/pyaedt_settings.yaml

# Custom instructions for GitHub Copilot
.github/copilot-instructions.md
1 change: 1 addition & 0 deletions doc/changelog.d/6727.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Conftest refactoring and local_config cleaning
14 changes: 7 additions & 7 deletions doc/source/Resources/pyaedt_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ log:
# Enable or disable the logging to a file
enable_file_logs: true
# Enable or disable the global PyAEDT log file located in the global temp folder
enable_global_log_file: true
enable_global_log_file: false
# Enable or disable the local PyAEDT log file located in the ``projectname.pyaedt`` project folder
enable_local_log_file: false
# Enable or disable the logging overall
Expand Down Expand Up @@ -92,29 +92,29 @@ general:
# AEDT version in the form ``"2023.x"``
aedt_version: null
# Timeout in seconds for trying to launch AEDT
desktop_launch_timeout: 120
desktop_launch_timeout: 180
# Enable or disable bounding box evaluation by exporting a SAT file
disable_bounding_box_sat: false
# Optional path for the EDB DLL file
edb_dll_path: null
# Enable or disable the internal PyAEDT error handling
enable_error_handler: true
enable_error_handler: false
# Enable or disable the use of Pandas to export dictionaries and lists
enable_pandas_output: false
enable_pandas_output: true
# Enable or disable the check of the project path
force_error_on_missing_project: false
# Number of gRPC API retries
number_of_grpc_api_retries: 6
# Enable or disable the release of AEDT on exception
release_on_exception: true
release_on_exception: false
# Time interval between the retries by the ``_retry_n_times`` inner method
retry_n_times_time_interval: 0.1
retry_n_times_time_interval: 0.5
# Enable or disable the use of the gRPC API or legacy COM object
use_grpc_api: null
# Enable or disable the use of multiple desktop sessions in the same Python script
use_multi_desktop: false
# Enable or disable the use of the flag `-waitforlicense` when launching AEDT
wait_for_license: false
wait_for_license: true
# State whether the remote API is used or not
remote_api: false
# Specify the port the RPyC server is to listen to
Expand Down
5 changes: 3 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
TESTS_PATH = Path(__file__).resolve().parent
TESTS_SYSTEM_PATH = TESTS_PATH / "system"
TESTS_UNIT_PATH = TESTS_PATH / "unit"
TESTS_EMIT_PATH = TESTS_SYSTEM_PATH / "emit"
TESTS_EXTENSIONS_PATH = TESTS_SYSTEM_PATH / "extensions"
TESTS_FILTER_SOLUTIONS_PATH = TESTS_SYSTEM_PATH / "filter_solutions"
TESTS_GENERAL_PATH = TESTS_SYSTEM_PATH / "general"
TESTS_SOLVERS_PATH = TESTS_SYSTEM_PATH / "solvers"
TESTS_VISUALIZATION_PATH = TESTS_SYSTEM_PATH / "visualization"
TESTS_EXTENSIONS_PATH = TESTS_SYSTEM_PATH / "extensions"
TESTS_FILTER_SOLUTIONS_PATH = TESTS_SYSTEM_PATH / "filter_solutions"
116 changes: 112 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,24 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import json
import os
from pathlib import Path
import random
import shutil
import string
import sys
import tempfile
from typing import List
from unittest.mock import MagicMock

import pytest

from ansys.aedt.core.aedt_logger import pyaedt_logger
from ansys.aedt.core.generic.settings import settings
from ansys.aedt.core.internal.filesystem import Scratch

# Test category prefixes for marker assignment
UNIT_TEST_PREFIX = "tests/unit"
INTEGRATION_TEST_PREFIX = "tests/integration"
SYSTEM_TEST_PREFIX = "tests/system"
Expand All @@ -39,6 +51,68 @@
EMIT_TEST_PREFIX = "tests/system/emit"


DEFAULT_CONFIG = {
"desktopVersion": "2025.2",
"NonGraphical": True,
"NewThread": True,
"use_grpc": True,
"close_desktop": True,
"remove_lock": False,
"disable_sat_bounding_box": True,
"use_local_example_data": False,
"local_example_folder": None,
"skip_circuits": False,
"skip_modelithics": True,
}

# Load top-level configuration
local_path = Path(__file__).parent
local_config_file = local_path / "local_config.json"

config = DEFAULT_CONFIG.copy()
if local_config_file.exists():
try:
with open(local_config_file) as f:
local_config = json.load(f)
config.update(local_config)
except Exception as e: # pragma: no cover
# Failed to load local_config.json; report error
print(f"Failed to load local_config.json ({local_config_file}): {e}")

desktop_version = config.get("desktopVersion", DEFAULT_CONFIG.get("desktopVersion"))
NONGRAPHICAL = config.get("NonGraphical", DEFAULT_CONFIG.get("NonGraphical"))
new_thread = config.get("NewThread", DEFAULT_CONFIG.get("NewThread"))
settings.use_grpc_api = config.get("use_grpc", DEFAULT_CONFIG.get("use_grpc"))
close_desktop = config.get("close_desktop", DEFAULT_CONFIG.get("close_desktop"))
remove_lock = config.get("remove_lock", DEFAULT_CONFIG.get("remove_lock"))
settings.disable_bounding_box_sat = config.get(
"disable_sat_bounding_box", DEFAULT_CONFIG.get("disable_sat_bounding_box")
)
settings.use_local_example_data = config.get("use_local_example_data", DEFAULT_CONFIG.get("use_local_example_data"))
if settings.use_local_example_data:
settings.local_example_folder = config.get("local_example_folder", DEFAULT_CONFIG.get("local_example_folder"))

logger = pyaedt_logger
os.environ["PYAEDT_SCRIPT_VERSION"] = config.get("desktopVersion", DEFAULT_CONFIG.get("desktopVersion"))


# Add current path to sys.path for imports
sys.path.append(str(local_path))


def generate_random_string(length):
"""Generate a random string of specified length."""
characters = string.ascii_letters + string.digits
random_string = "".join(random.sample(characters, length))
return random_string


def generate_random_ident():
"""Generate a random identifier for test folders."""
ident = "-" + generate_random_string(6) + "-" + generate_random_string(6) + "-" + generate_random_string(6)
return ident


def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item]):
"""Hook used to apply marker on tests."""
for item in items:
Expand All @@ -64,8 +138,41 @@ def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item
item.add_marker(pytest.mark.emit)


# ================================
# SHARED FIXTURES
# ================================


@pytest.fixture(scope="session", autouse=True)
def init_scratch():
"""Initialize a global scratch directory for all tests."""
test_folder_name = "pyaedt_test" + generate_random_ident()
test_folder = Path(tempfile.gettempdir()) / test_folder_name
try:
os.makedirs(test_folder, mode=0o777)
except FileExistsError as e:
print(f"Failed to create {test_folder}. Reason: {e}")

yield test_folder

try:
shutil.rmtree(test_folder, ignore_errors=True)
except Exception as e:
print(f"Failed to delete {test_folder}. Reason: {e}")


@pytest.fixture(scope="module", autouse=True)
def local_scratch(init_scratch):
"""Provide a module-scoped scratch directory."""
tmp_path = init_scratch
scratch = Scratch(tmp_path)
yield scratch
scratch.remove()


@pytest.fixture
def touchstone_file(tmp_path):
"""Create a dummy touchstone file for testing."""
file_path = tmp_path / "dummy.s2p"
file_content = """
! Terminal data exported
Expand All @@ -80,6 +187,7 @@ def touchstone_file(tmp_path):

@pytest.fixture()
def patch_graphics_modules(monkeypatch):
"""Patch graphics modules to avoid headless env issues."""
modules = [
"matplotlib",
"matplotlib.pyplot",
Expand All @@ -100,9 +208,9 @@ def patch_graphics_modules(monkeypatch):

# Specific action to make a mock an attribute of another mock
mocks["matplotlib"].pyplot = mocks["matplotlib.pyplot"]
mocks["ansys.tools.visualization_interface"].backends = mocks["ansys.tools.visualization_interface.backends"]
mocks["ansys.tools.visualization_interface.backends"].pyvista = mocks[
"ansys.tools.visualization_interface.backends.pyvista"
]
viz_interface = mocks["ansys.tools.visualization_interface"]
viz_backends = mocks["ansys.tools.visualization_interface.backends"]
viz_interface.backends = viz_backends
viz_backends.pyvista = mocks["ansys.tools.visualization_interface.backends.pyvista"]

yield mocks
18 changes: 18 additions & 0 deletions tests/pyaedt_settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# PyAEDT settings configuration for test environment
# This file configures PyAEDT settings for all tests

log:
enable_local_log_file: false
enable_global_log_file: false
enable_desktop_logs: false

general:
number_of_grpc_api_retries: 6
retry_n_times_time_interval: 0.5
enable_error_handler: false
desktop_launch_timeout: 180
release_on_exception: false
wait_for_license: true
enable_pandas_output: true
lsf: {}
# LSF settings are kept at defaults for test environment
Loading
Loading