Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@


class StreamingParityTests(StreamingTestsMixin, ReusedConnectTestCase):
pass
def _assert_exception_tree_contains_msg(self, exception, msg):
self.assertTrue(
msg in exception._message,
"Exception tree doesn't contain the expected message: %s" % msg,
)


if __name__ == "__main__":
Expand Down
29 changes: 7 additions & 22 deletions python/pyspark/sql/tests/streaming/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from pyspark.sql.functions import lit
from pyspark.sql.types import StructType, StructField, IntegerType, StringType
from pyspark.testing.sqlutils import ReusedSQLTestCase
from pyspark.errors.exceptions.connect import SparkConnectException


class StreamingTestsMixin:
Expand Down Expand Up @@ -295,26 +294,6 @@ def test_stream_exception(self):
self.assertIsInstance(exception, StreamingQueryException)
self._assert_exception_tree_contains_msg(exception, "ZeroDivisionError")

def _assert_exception_tree_contains_msg(self, exception, msg):
if isinstance(exception, SparkConnectException):
self._assert_exception_tree_contains_msg_connect(exception, msg)
else:
self._assert_exception_tree_contains_msg_default(exception, msg)

def _assert_exception_tree_contains_msg_connect(self, exception, msg):
self.assertTrue(
msg in exception._message,
"Exception tree doesn't contain the expected message: %s" % msg,
)

def _assert_exception_tree_contains_msg_default(self, exception, msg):
e = exception
contains = msg in e._desc
while e._cause is not None and not contains:
e = e._cause
contains = msg in e._desc
self.assertTrue(contains, "Exception tree doesn't contain the expected message: %s" % msg)

def test_query_manager_get(self):
df = self.spark.readStream.format("rate").load()
for q in self.spark.streams.active:
Expand Down Expand Up @@ -408,7 +387,13 @@ def test_streaming_with_temporary_view(self):


class StreamingTests(StreamingTestsMixin, ReusedSQLTestCase):
pass
def _assert_exception_tree_contains_msg(self, exception, msg):
e = exception
contains = msg in e._desc
while e._cause is not None and not contains:
e = e._cause
contains = msg in e._desc
self.assertTrue(contains, "Exception tree doesn't contain the expected message: %s" % msg)


if __name__ == "__main__":
Expand Down