Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling pytest from python code since skip list too long #1044

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions test/xpu/extended/run_test_with_skip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pytest
import sys
from skip_list_common import skip_dict
from skip_list_win import skip_dict as skip_dict_win
Expand All @@ -9,14 +10,12 @@
if IS_WINDOWS:
skip_list += skip_dict_win["test_ops_xpu.py"]

skip_options = " -k \"not " + skip_list[0]
skip_options = "not " + skip_list[0]
for skip_case in skip_list[1:]:
skip_option = " and not " + skip_case
skip_options += skip_option
skip_options += "\""

os.environ["PYTORCH_TEST_WITH_SLOW"]="1"
test_command = "pytest -v test_ops_xpu.py"
test_command += skip_options
res = os.system(test_command)
test_command = ["-k", skip_options, "test_ops_xpu.py", "-v"]
res = pytest.main(test_command)
sys.exit(res)
9 changes: 4 additions & 5 deletions test/xpu/extended/run_test_with_skip_arc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pytest
import sys
from skip_list_common import skip_dict
from skip_list_arc import skip_dict as skip_dict_specifical
Expand All @@ -11,14 +12,12 @@
if IS_WINDOWS:
skip_list += skip_dict_win["test_ops_xpu.py"] + skip_dict_win_arc["test_ops_xpu.py"]

skip_options = " -k \"not " + skip_list[0]
skip_options = "not " + skip_list[0]
for skip_case in skip_list[1:]:
skip_option = " and not " + skip_case
skip_options += skip_option
skip_options += "\""

os.environ["PYTORCH_TEST_WITH_SLOW"]="1"
test_command = "pytest -v test_ops_xpu.py"
test_command += skip_options
res = os.system(test_command)
test_command = ["-k", skip_options, "test_ops_xpu.py", "-v"]
res = pytest.main(test_command)
sys.exit(res)
35 changes: 16 additions & 19 deletions test/xpu/xpu_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import copy
import os
import pytest
import sys
import unittest

Expand Down Expand Up @@ -1037,30 +1038,26 @@ def launch_test(test_case, skip_list=None, exe_list=None):
os.environ["PYTORCH_ENABLE_XPU_FALLBACK"]="1"
os.environ["PYTORCH_TEST_WITH_SLOW"]="1"
if skip_list != None:
skip_options = " -k \"not " + skip_list[0]
skip_options = "not " + skip_list[0]
for skip_case in skip_list[1:]:
skip_option = " and not " + skip_case
skip_options += skip_option
skip_options += "\""
test_command = (
"pytest -v "
+ test_case
)
test_command += skip_options
if test_case == "test_dataloader_xpu.py":
test_command = ["-k", skip_options, "-n", "1", test_case, "-v"]
else:
test_command = ["-k", skip_options, test_case, "-v"]
elif exe_list != None:
exe_options = " -k \"" + exe_list[0]
exe_options = exe_list[0]
for exe_case in exe_list[1:]:
exe_option = " or " + exe_case
exe_options += exe_option
exe_options += "\""
test_command = (
"pytest -v "
+ test_case
)
test_command += exe_options
if test_case == "test_dataloader_xpu.py":
test_command = ["-k", exe_options, "-n", "1", test_case, "-v"]
else:
test_command = ["-k", exe_options, test_case, "-v"]
else:
test_command = (
"pytest -v "
+ test_case
)
return os.system(test_command)
if test_case == "test_dataloader_xpu.py":
test_command = ["-n", "1", test_case, "-v"]
else:
test_command = [test_case, "-v"]
return pytest.main(test_command)
Loading