Skip to content

Commit 0ba9a9b

Browse files
gaogaotiantianHyukjinKwon
authored andcommitted
[SPARK-54474][PYTHON] Discard the XML report on tests that are supposed to fail
### What changes were proposed in this pull request? We do not keep the XML reports from the tests that are supposed to fail anymore. ### Why are the changes needed? It will confuse XML report consumers. These are tests that are supposed to fail - we are testing if they return the expected return code. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Manually tested that no XML report is generated and the test itself still passes. ### Was this patch authored or co-authored using generative AI tooling? No Closes #53187 from gaogaotiantian/disable-xml-on-failed-tests. Authored-by: Tian Gao <gaogaotiantian@hotmail.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 92c948f commit 0ba9a9b

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

python/pyspark/testing/tests/test_fail.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17+
18+
import tempfile
1719
import unittest
1820

1921

@@ -25,13 +27,16 @@ def test_something(self):
2527
if __name__ == "__main__":
2628
from pyspark.testing.tests.test_fail import * # noqa: F401
2729

28-
try:
29-
import xmlrunner
30+
# Do not keep XML report because the test is supposed to fail.
31+
# We do not want to confuse XML report consumers.
32+
with tempfile.TemporaryDirectory() as tmpdir:
33+
try:
34+
import xmlrunner
3035

31-
testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2)
32-
except ImportError:
33-
testRunner = None
34-
try:
35-
unittest.main(testRunner=testRunner, verbosity=2)
36-
except SystemExit as e:
37-
assert e.code == 1, f"status code: {e.code}"
36+
testRunner = xmlrunner.XMLTestRunner(output=tmpdir, verbosity=2)
37+
except ImportError:
38+
testRunner = None
39+
try:
40+
unittest.main(testRunner=testRunner, verbosity=2)
41+
except SystemExit as e:
42+
assert e.code == 1, f"status code: {e.code}"

python/pyspark/testing/tests/test_fail_in_set_up_class.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17+
18+
import tempfile
1719
import unittest
1820

1921

@@ -30,13 +32,16 @@ def test_something(self):
3032
if __name__ == "__main__":
3133
from pyspark.testing.tests.test_fail_in_set_up_class import * # noqa: F401
3234

33-
try:
34-
import xmlrunner
35+
# Do not keep XML report because the test is supposed to fail.
36+
# We do not want to confuse XML report consumers.
37+
with tempfile.TemporaryDirectory() as tmpdir:
38+
try:
39+
import xmlrunner
3540

36-
testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2)
37-
except ImportError:
38-
testRunner = None
39-
try:
40-
unittest.main(testRunner=testRunner, verbosity=2)
41-
except SystemExit as e:
42-
assert e.code == 1, f"status code: {e.code}"
41+
testRunner = xmlrunner.XMLTestRunner(output=tmpdir, verbosity=2)
42+
except ImportError:
43+
testRunner = None
44+
try:
45+
unittest.main(testRunner=testRunner, verbosity=2)
46+
except SystemExit as e:
47+
assert e.code == 1, f"status code: {e.code}"

0 commit comments

Comments
 (0)