Skip to content
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
23 changes: 14 additions & 9 deletions python/pyspark/testing/tests/test_fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

import tempfile
import unittest


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

try:
import xmlrunner
# Do not keep XML report because the test is supposed to fail.
# We do not want to confuse XML report consumers.
with tempfile.TemporaryDirectory() as tmpdir:
try:
import xmlrunner

testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2)
except ImportError:
testRunner = None
try:
unittest.main(testRunner=testRunner, verbosity=2)
except SystemExit as e:
assert e.code == 1, f"status code: {e.code}"
testRunner = xmlrunner.XMLTestRunner(output=tmpdir, verbosity=2)
except ImportError:
testRunner = None
try:
unittest.main(testRunner=testRunner, verbosity=2)
except SystemExit as e:
assert e.code == 1, f"status code: {e.code}"
23 changes: 14 additions & 9 deletions python/pyspark/testing/tests/test_fail_in_set_up_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

import tempfile
import unittest


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

try:
import xmlrunner
# Do not keep XML report because the test is supposed to fail.
# We do not want to confuse XML report consumers.
with tempfile.TemporaryDirectory() as tmpdir:
try:
import xmlrunner

testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2)
except ImportError:
testRunner = None
try:
unittest.main(testRunner=testRunner, verbosity=2)
except SystemExit as e:
assert e.code == 1, f"status code: {e.code}"
testRunner = xmlrunner.XMLTestRunner(output=tmpdir, verbosity=2)
except ImportError:
testRunner = None
try:
unittest.main(testRunner=testRunner, verbosity=2)
except SystemExit as e:
assert e.code == 1, f"status code: {e.code}"