Skip to content

Commit bbfea87

Browse files
committed
Fix the bug that Streaming Python tests cannot report failures
1 parent 08660a0 commit bbfea87

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

python/pyspark/streaming/tests.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,11 +1322,17 @@ def search_kinesis_asl_assembly_jar():
13221322
"or 'build/mvn -Pkinesis-asl package' before running this test.")
13231323

13241324
sys.stderr.write("Running tests: %s \n" % (str(testcases)))
1325+
failed = False
13251326
for testcase in testcases:
13261327
sys.stderr.write("[Running %s]\n" % (testcase))
13271328
tests = unittest.TestLoader().loadTestsFromTestCase(testcase)
13281329
if xmlrunner:
1329-
unittest.main(tests, verbosity=3,
1330-
testRunner=xmlrunner.XMLTestRunner(output='target/test-reports'))
1330+
result = unittest.main(tests, verbosity=3,
1331+
testRunner=xmlrunner.XMLTestRunner(output='target/test-reports'))
1332+
if not result.wasSuccessful():
1333+
failed = True
13311334
else:
1332-
unittest.TextTestRunner(verbosity=3).run(tests)
1335+
result = unittest.TextTestRunner(verbosity=3).run(tests)
1336+
if not result.wasSuccessful():
1337+
failed = True
1338+
sys.exit(failed)

0 commit comments

Comments
 (0)