Skip to content

Commit

Permalink
Merge branch 'fix/windows-tests' of https://github.com/ansys/pymapdl
Browse files Browse the repository at this point in the history
…into fix/windows-tests
  • Loading branch information
germa89 committed Mar 20, 2024
2 parents ae1ce22 + ccd3ea4 commit bf10d17
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
58 changes: 28 additions & 30 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
from ansys.mapdl.core.licensing import LICENSES
from conftest import ON_LOCAL, QUICK_LAUNCH_SWITCHES, NullContext, requires

PORT_TEST = 50053

try:
from ansys.tools.path import (
find_ansys,
Expand Down Expand Up @@ -183,21 +181,21 @@ def test_launch_console(version):

@requires("local")
@requires("nostudent")
def test_license_type_keyword():
def test_license_type_keyword(mapdl):
checks = []
for license_name, license_description in LICENSES.items():
try:
mapdl = launch_mapdl(
mapdl_ = launch_mapdl(
license_type=license_name,
start_timeout=start_timeout,
port=PORT_TEST,
port=mapdl.port + 1,
additional_switches=QUICK_LAUNCH_SWITCHES,
)

# Using first line to ensure not picking up other stuff.
checks.append(license_description in mapdl.__str__().split("\n")[0])
mapdl.exit()
del mapdl
checks.append(license_description in mapdl_.__str__().split("\n")[0])
mapdl_.exit()
del mapdl_
sleep(2)

except MapdlDidNotStart as e:
Expand All @@ -211,45 +209,45 @@ def test_license_type_keyword():

@requires("local")
@requires("nostudent")
def test_license_type_keyword_names():
def test_license_type_keyword_names(mapdl):
# This test might became a way to check available licenses, which is not the purpose.

successful_check = False
for license_name, license_description in LICENSES.items():
mapdl = launch_mapdl(
mapdl_ = launch_mapdl(
license_type=license_name,
start_timeout=start_timeout,
port=PORT_TEST,
port=mapdl.port + 1,
additional_switches=QUICK_LAUNCH_SWITCHES,
)

# Using first line to ensure not picking up other stuff.
successful_check = (
license_description in mapdl.__str__().split("\n")[0] or successful_check
license_description in mapdl_.__str__().split("\n")[0] or successful_check
)
assert license_description in mapdl.__str__().split("\n")[0]
mapdl.exit()
assert license_description in mapdl_.__str__().split("\n")[0]
mapdl_.exit()

assert successful_check # if at least one license is ok, this should be true.


@requires("local")
@requires("nostudent")
def test_license_type_additional_switch():
def test_license_type_additional_switch(mapdl):
# This test might became a way to check available licenses, which is not the purpose.
successful_check = False
for license_name, license_description in LICENSES.items():
mapdl = launch_mapdl(
mapdl_ = launch_mapdl(
additional_switches=QUICK_LAUNCH_SWITCHES + " -p " + license_name,
start_timeout=start_timeout,
port=PORT_TEST,
port=mapdl.port + 1,
)

# Using first line to ensure not picking up other stuff.
successful_check = (
license_description in mapdl.__str__().split("\n")[0] or successful_check
license_description in mapdl_.__str__().split("\n")[0] or successful_check
)
mapdl.exit()
mapdl_.exit()

assert successful_check # if at least one license is ok, this should be true.

Expand All @@ -260,7 +258,7 @@ def test_license_type_dummy(mapdl):
dummy_license_type = "dummy"
with pytest.raises(LicenseServerConnectionError):
launch_mapdl(
port=PORT_TEST,
port=mapdl.port + 1,
additional_switches=f" -p {dummy_license_type}" + QUICK_LAUNCH_SWITCHES,
start_timeout=start_timeout,
)
Expand All @@ -270,16 +268,16 @@ def test_license_type_dummy(mapdl):
@requires("nostudent")
def test_remove_temp_files(mapdl):
"""Ensure the working directory is removed when run_location is not set."""
mapdl = launch_mapdl(
port=PORT_TEST,
mapdl_ = launch_mapdl(
port=mapdl.port + 1,
remove_temp_files=True,
start_timeout=start_timeout,
additional_switches=QUICK_LAUNCH_SWITCHES,
)

# possible MAPDL is installed but running in "remote" mode
path = mapdl.directory
mapdl.exit()
path = mapdl_.directory
mapdl_.exit()

tmp_dir = tempfile.gettempdir()
ans_temp_dir = os.path.join(tmp_dir, "ansys_")
Expand All @@ -293,17 +291,17 @@ def test_remove_temp_files(mapdl):
@requires("nostudent")
def test_remove_temp_files_fail(tmpdir, mapdl):
"""Ensure the working directory is not removed when the cwd is changed."""
mapdl = launch_mapdl(
port=PORT_TEST,
mapdl_ = launch_mapdl(
port=mapdl.port + 1,
remove_temp_files=True,
start_timeout=start_timeout,
additional_switches=QUICK_LAUNCH_SWITCHES,
)
old_path = mapdl.directory
old_path = mapdl_.directory
assert os.path.isdir(str(tmpdir))
mapdl.cwd(str(tmpdir))
path = mapdl.directory
mapdl.exit()
mapdl_.cwd(str(tmpdir))
path = mapdl_.directory
mapdl_.exit()
assert os.path.isdir(path)

# Checking no changes in the old path
Expand Down
2 changes: 1 addition & 1 deletion tests/test_licensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ def test_check_license_file(mapdl, tmpdir):

try:
mapdl_ = launch_mapdl(
port=mapdl.port + 1,
license_server_check=False,
start_timeout=timeout,
additional_switches=QUICK_LAUNCH_SWITCHES,
port=mapdl.port + 1,
)
assert mapdl_._local
mapdl_.exit()
Expand Down

0 comments on commit bf10d17

Please sign in to comment.