Skip to content

Commit 6181fc0

Browse files
Alberto-DMmaxcapodi78pre-commit-ci[bot]PipKat
authored
Desktop refactoring - unit test refactoring (#3342)
* First refactoring of Desktop class init * - moved installed_versions, current_version, current_student_version under misc - refactored active_sessions, com_active_sessions, grpc_active_sessions * - minor clean-up and renaming * - aedt_process_id is now a Desktop property (removed from settings) - is_student is now a desktop property (removed from settings) * implemented desktop sessions * fixed small bug in release_desktop * - removed non_graphical, machine and port from settings. They are now in class Desktop - introduced variable Desktop._invoked_from_design and method _init_desktop_from_design * - created _init_from_design - added test_launch_desktop.py to unittests * - merged settings.py * - docstring fixed * - refactored Desktop._close_aedt_application - removed Desktop.force_close_desktop - added GeneralMethods.is_process_running - modified test_42_configuration_files.py * - added settings.retry_n_times_time_interval and used to increase the time during tests. * - fix in test_13_link_array - fix in test_11_create_via * - fixed _close_aedt_application with timeout before force closing desktop * - fixed logger handler loading to proper disable file logging in unittest - fixed bug in components_3d.py * - userlib, personallib, syslib from Design class are now calling the properties from Desktop - fixed exception in __Invoke__ method from grpc_plugin.py * - set exclusion_list in __Invoke__ method from grpc_plugin.py * Apply suggestions from code review * - test unittests with 23R1 - removed exceptions types in __Invoke__ * removed setup method test * removed desktop object auto-destruction * disabling a UT for test * UT on 23R2 * desktop sessions are now outside Desktop class removed QuitApplication * fix in SBR+ test to avoid to invalidate solutions * removed sys.exit() from __Invoke__ * doubled troublesome analyzes in tests * testing duplicated Desktops * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove aedt_logger from pyaedt init. Removed global messages from unit tests * remove aedt_logger from pyaedt init. Removed global messages from unit tests * remove aedt_logger from pyaedt init. Removed global messages from unit tests * changed test * updated Example * updated Example * restored Desktop.py * messages in _close_aedt_application * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Improved retry_ntimes on Get Methods * Apply suggestions from code review Co-authored-by: Kathy Pippert <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed docstrings * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply suggestions from code review Co-authored-by: Kathy Pippert <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed docstrings * test removing Desktop._invoked_from_design * restored Desktop._invoked_from_design * test temp folder change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactored conftest.py and test_21_Circuit.py with fixtures. Looses compatibility with IronPython. * refactored test_00_EDB.py and test_00_Advanced_EDB.py with fixtures. * refactored test_01_downloads.py with fixtures. * refactored test_01_Design.py with fixtures. One error. * refactored test_01_Design.py with fixtures. No errors. * refactored test_01_GeometryOperators.py with fixtures. * refactored test_01_pdf.py with fixtures. * refactored test_01_pdf.py with fixtures. * added override to desktop fixture to avoid launching desktop in specific modules. * refactored test_01_report_file_parser.py.py with fixtures. * refactored test_01_toolkit_icons.py.py.py with fixtures. * refactored test_02_2D_modeler.py with fixtures. * refactored test_02_3D_modeler.py with fixtures. * refactored test_03_Materials.py with fixtures. * refactored test_05_Mesh.py with fixtures. * refactored test_06_MessageManager.py with fixtures. * refactored test_07_Object3D.py with fixtures. * refactored test_08_Primitives3D.py with fixtures. * update examples fixture in test_21_Circuit.py. * refactored test_09_Primitives2D.py with fixtures. * refactored test_09_VariableManager.py with fixtures. * refactored test_11_Setup.py with fixtures. * refactored test_12_1_PostProcessing.py with fixtures. * imposed use of add_app fixture in test_03_Materials.py * refactored test_12_PostProcessing.py with fixtures. * added just_open argument to add_app fixture. * refactored test_13_LoadAEDTFile.py with fixtures. * imposed use of add_app fixture in test_05_Mesh.py * imposed use of add_app fixture in test_12_1_PostProcessing.py * imposed use of add_app fixture in test_12_1_PostProcessing.py * refactored test_14_AedtLogger.py with fixtures. * refactored test_15_ibs_reader.py with fixtures. * refactored test_16_3d_stackup.py with fixtures. * refactored test_17_SBR.py with fixtures. * refactored test_20_HFSS.py.py with fixtures. * refactored test_22_Circuit_DynamicLink.py with fixtures. * refactored test_26_emit.py with fixtures. * refactored test_27_Maxwell2D.py with fixtures. * refactored test_28_Maxwell3D.py with fixtures. * refactored test_29_Mechanical.py with fixtures. * refactored test_30_Q2D.py with fixtures. * removed unused example file in test_28_Maxwell3D.py * refactored test_31_Q3D.py with fixtures. * refactored test_32_RMxprt.py with fixtures. * refactored test_34_TwinBuilder.py with fixtures. * refactored test_35_MaxwellCircuit.py with fixtures. * refactored test_36_Q2D_PostProcessing.py with fixtures. * refactored test_37_Genetic_Algorithm.py with fixtures. * refactored test_40_3dlayout_edb.py with fixtures. * refactored test_41_3dlayout_modeler.py with fixtures. Simplified simulation. * refactored test_42_configuration_files.py with fixtures. * refactored test_43_CableModeling.py with fixtures. * refactored test_44_TouchstoneParser.py with fixtures. * refactored test_98_Icepak.py with fixtures. * refactored test_launch_desktop.py with fixtures. * triggered pre-commit hook * black and flake reformatting * implementing docstring review * TEST: using COM for unit tests * fix number of parallel tests * added fixtures to single tests when multiple AEDT projects are loaded * added fixtures to single tests when multiple AEDT projects are loaded * fixed test_26_emit.py after merge * fixed test_26_emit.py after merge * Apply suggestions from code review Co-authored-by: Kathy Pippert <[email protected]> * Apply suggestions from code review Co-authored-by: Kathy Pippert <[email protected]> * PipKat review * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Created new Ironpython tests * Added test-class retry * improved IronPython tests * removed ironpython references in the unittests * set CI_Ironpython for new IronPython unit tests * added pytest-timeout * fixed bugs in ironpython.yml set option for --timeout in unit_tests.yml * set option for --timeout in unit_tests.yml * set option for --timeout in unit_tests.yml * set "-n 6" instead of "--tx 6*popen" * restored "--tx 6*popen" removed timeout * set "--tx 3*popen" removed "--maxretry 2" * removed from pytest.ini: doctest_optionflags = ELLIPSIS addopts = --doctest-modules -p no:faulthandler removed from unit_tests.yml: --cov=pyaedt --cov-report=xml --cov-report=html * removed @pytest.mark.timeout decorator * removed "pytest-retry-class==0.1", "pytest-timeout==2.1.0", from pyproject.toml * increased to 4 * merge from main fixed f string for IronPython * set "-n 4" instead of "--tx 4*popen" * Separated unit tests for solvers. They will run sequentially. * fixed multiple report files * Fixed references and moved additional 2 tests files * Fixed references and moved additional 2 tests files * Fixed references and moved additional 2 tests files * added __init__.py to _unittest_solvers fixed some bugs * revert changes * moved folder NF_Test created T34 example folder * modified getignore * extracted LayoutForce.aedtz * removed ignored file local_config.json from server * removed ignored file local_config.json from server restored --tx 4*popen * created a separate job for the solvers unit tests * -n 2 option * fixed test_19C_export_touchsthone * moved test_41_3dlayout_modeler.py under _unittest_solvers * moved cad files for test_41_3dlayout_modeler.py under _unittest_solvers\example_models * -n 4 option * added num_cores=6 to all analyze methods * fixed test_result_categories in test_26_emit.py * created test_00_analyze.py to collect all solve tests * fixed bug in test_41_3dlayout_modeler.py * fixed test_00_analyze.py * merge from main * -n 6 option * moved sbr_create_vrt and sbr_create_vrt_creeping to test_00_analyze.py * removed comments * removed comments and unused files * moved cad files for test_41_3dlayout_modeler.py to _unittest folder * moved test_98_Icepak.py to _unittest_solvers * -n 4 option * moved tests to parallel * Updated to 8 cores --------- Co-authored-by: Massimo Capodiferro <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: maxcapodi78 <Shark78> Co-authored-by: Kathy Pippert <[email protected]>
1 parent 0c47a72 commit 6181fc0

File tree

163 files changed

+42929
-6045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+42929
-6045
lines changed

.github/labeler.yml

-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,5 @@ dependencies:
1111
- requirements/**/*
1212
testing:
1313
- _unittest/conftest.py
14-
- _unittest/launch_desktop_tests.py
15-
- _unittest_ironpython/generate_tests.py
16-
- _unittest_ironpython/conf_unittest.py
1714
- _unittest_ironpython/run_unittests.py
1815
- _unittest_ironpython/run_unittests_batchmode.cmd
19-
- _unittest_ironpython/run_unittests_batchmode_linux.cmd

.github/workflows/ironpython.yml

+3-24
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,10 @@ jobs:
2626
- name: 'Run Unit Tests in Ironpython'
2727
timeout-minutes: 60
2828
run: |
29-
Remove-Item d:\Temp\* -Recurse -Force
30-
Set-Item -Path env:ANS_MESHER_PROC_DUMP_PREPOST_BEND_SM3 -Value "1"
31-
Set-Item -Path env:ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE -Value "1"
32-
Set-Item -Path env:ANSYSEM_FEATURE_SF159726_SCRIPTOBJECT_ENABLE -Value "1"
33-
Set-Item -Path env:ANSYSEM_FEATURE_SF222134_CABLE_MODELING_ENHANCEMENTS_ENABLE -Value "1"
34-
Set-Item -Path env:ANSYSEM_FEATURE_F395486_RIGID_FLEX_BENDING_ENABLE -Value "1"
35-
Set-Item -Path env:ANSYSEM_FEATURE_S432616_LAYOUT_COMPONENT_IN_3D_ENABLE -Value "1"
36-
$processA = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd --test-filter test_0*.py' -PassThru
37-
$processB = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd --test-filter test_1*.py' -PassThru
38-
$processC = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd --test-filter test_2*.py' -PassThru
39-
$processD = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd --test-filter test_3*.py' -PassThru
40-
$processE = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd --test-filter test_4*.py' -PassThru
41-
$processF = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd --test-filter test_9*.py' -PassThru
42-
43-
$processC.WaitForExit()
44-
$processD.WaitForExit()
45-
$processE.WaitForExit()
29+
$processA = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd' -PassThru
4630
$processA.WaitForExit()
47-
$processB.WaitForExit()
48-
$processF.WaitForExit()
49-
50-
get-content .\_unittest_ironpython\runner_unittest.log
51-
52-
$test_errors_failures = Select-String -Path .\_unittest_ironpython\runner_unittest.log -Pattern "TextTestResult errors="
53-
31+
get-content .\_unittest_ironpython\pyaedt_unit_test_ironpython.log
32+
$test_errors_failures = Select-String -Path .\_unittest_ironpython\pyaedt_unit_test_ironpython.log -Pattern "TextTestResult errors="
5433
if ($test_errors_failures -ne $null)
5534
{
5635
exit 1

.github/workflows/unit_tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ env:
66
# Following env vars when changed will "reset" the mentioned cache,
77
# by changing the cache file name. It is rendered as ...-v%RESET_XXX%-...
88
# You should go up in number, if you go down (or repeat a previous value)
9-
# you might end up reusing a previous cache if it haven't been deleted already.
9+
# you might end up reusing a previous cache if it hasn't been deleted already.
1010
# It applies 7 days retention policy by default.
1111
RESET_PIP_CACHE: 0
1212
PACKAGE_NAME: PyAEDT
@@ -70,7 +70,7 @@ jobs:
7070
run: |
7171
testenv\Scripts\Activate.ps1
7272
Set-Item -Path env:PYTHONMALLOC -Value "malloc"
73-
pytest --tx 8*popen --durations=50 --dist loadfile -v --cov=pyaedt --cov-report=xml --junitxml=junit/test-results.xml --cov-report=html _unittest
73+
pytest -n 8 --dist loadfile --durations=50 -v --cov=pyaedt --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest
7474
7575
- uses: codecov/codecov-action@v3
7676
if: matrix.python-version == '3.10'
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI_Solvers
2+
3+
env:
4+
python.version: '3.10'
5+
python.venv: 'testvenv'
6+
# Following env vars when changed will "reset" the mentioned cache,
7+
# by changing the cache file name. It is rendered as ...-v%RESET_XXX%-...
8+
# You should go up in number, if you go down (or repeat a previous value)
9+
# you might end up reusing a previous cache if it hasn't been deleted already.
10+
# It applies 7 days retention policy by default.
11+
RESET_PIP_CACHE: 0
12+
PACKAGE_NAME: PyAEDT
13+
# Controls when the workflow will run
14+
on:
15+
# Triggers the workflow on push or pull request events but only for the main branch
16+
push:
17+
tags:
18+
- 'v*'
19+
branches:
20+
- main
21+
pull_request:
22+
branches: [ main ]
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
29+
jobs:
30+
# This workflow contains a single job called "build"
31+
build:
32+
# The type of runner that the job will run on
33+
runs-on: [windows-latest, pyaedt]
34+
strategy:
35+
matrix:
36+
python-version: ['3.10']
37+
# Steps represent a sequence of tasks that will be executed as part of the job
38+
steps:
39+
- uses: actions/checkout@v3
40+
- name: Set up Python ${{ matrix.python-version }}
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: ${{ matrix.python-version }}
44+
45+
- name: 'Create virtual env'
46+
run: |
47+
Remove-Item D:\Temp\* -Recurse -Force
48+
python -m venv testenv_s
49+
testenv_s\Scripts\Activate.ps1
50+
python -m pip install pip -U
51+
python -m pip install wheel setuptools -U
52+
python -c "import sys; print(sys.executable)"
53+
54+
- name: 'Install pyaedt'
55+
run: |
56+
testenv_s\Scripts\Activate.ps1
57+
pip install .
58+
pip install .[tests]
59+
pip install pytest-azurepipelines
60+
Copy-Item -Path "C:\actions-runner\opengl32.dll" -Destination "testenv_s\Lib\site-packages\vtkmodules" -Force
61+
mkdir tmp
62+
cd tmp
63+
python -c "import pyaedt; print('Imported pyaedt')"
64+
65+
# - name: "Check licences of packages"
66+
# uses: pyansys/pydpf-actions/[email protected]
67+
68+
- name: 'Unit testing'
69+
timeout-minutes: 40
70+
run: |
71+
testenv_s\Scripts\Activate.ps1
72+
Set-Item -Path env:PYTHONMALLOC -Value "malloc"
73+
pytest --durations=50 -v --cov=pyaedt --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest_solvers
74+
75+
- uses: codecov/codecov-action@v3
76+
if: matrix.python-version == '3.10'
77+
name: 'Upload coverage to Codecov'
78+
79+
- name: Upload pytest test results
80+
uses: actions/upload-artifact@v3
81+
with:
82+
name: pytest-results
83+
path: junit/test-results.xml
84+
# Use always() to always run this step to publish test results when there are test failures
85+
if: ${{ always() }}
86+
87+
- name: 'Build and validate source distribution'
88+
run: |
89+
testenv_s\Scripts\Activate.ps1
90+
python -m pip install build twine
91+
python -m build
92+
python -m twine check dist/*
93+
94+
- name: "Builds and uploads to PyPI"
95+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
96+
run: |
97+
testenv_s\Scripts\Activate.ps1
98+
python setup.py sdist
99+
python -m pip install twine
100+
python -m twine upload --skip-existing dist/*
101+
env:
102+
TWINE_USERNAME: __token__
103+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ dist/
373373
/coverage.xml
374374
/_unittest/coverage.xml
375375
/_unittest/local_config.json
376+
/_unittest_solvers/coverage.xml
377+
/_unittest_solvers/local_config.json
376378
test-results.xml
377379
test-output.xml
378380

0 commit comments

Comments
 (0)