nsivarajan commented on code in PR #29912:
URL: https://github.com/apache/superset/pull/29912#discussion_r1738375979


##########
tests/unit_tests/async_events/async_query_manager_tests.py:
##########
@@ -26,17 +27,27 @@
     AsyncQueryManager,
     AsyncQueryTokenException,
 )
+from superset.async_events.cache_backend import (
+    RedisCacheBackend,
+    RedisSentinelCacheBackend,
+)
 
 JWT_TOKEN_SECRET = "some_secret"
 JWT_TOKEN_COOKIE_NAME = "superset_async_jwt"
 
+# Define the cache backends once as mocks
+cache_backends = {
+    "RedisCacheBackend": mock.Mock(spec=RedisCacheBackend),
+    "RedisSentinelCacheBackend": mock.Mock(spec=RedisSentinelCacheBackend),
+    "redis.Redis": mock.Mock(spec=redis.Redis),
+}
+

Review Comment:
   Thanks, @villebro , for the review. I agree that using the standard approach 
is ideal. However, I've encountered continuous failures when combining 
`pytest.mark.parametrize` with `mock`, which suggests there might be 
compatibility issues. After some research, I found references that indicate 
potential conflicts when using pytest features with unittest.TestCase 
subclasses and mock (see [pytest 
documentation](https://docs.pytest.org/en/stable/how-to/unittest.html#pytest-features-in-unittest-testcase-subclasses),
 [SeleniumBase issue](https://github.com/seleniumbase/SeleniumBase/issues/395), 
and [pytest 
issue](https://github.com/pytest-dev/pytest/issues/541#issuecomment-609956951)).
   
   I noticed that our repository already uses `parameterized.expand` in similar 
cases, so I opted for it here to ensure the tests run smoothly.
   
   Would it be possible to proceed with this PR using `parameterized.expand`? 
I'll continue investigating the issues with `pytest.mark.parametrize` and 
`mock` and plan to submit a follow-up PR if I find a viable solution.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to