test(python-client): fix silent-skip anti-pattern in test_gremlin.py setUpClass (#327)#336
Open
Muawiya-contact wants to merge 1 commit into
Open
Conversation
…setUpClass - Remove automatic connectivity probe that silently skipped all 6 Gremlin integration tests on 404 / timeout / connection error - Endpoint failures now surface as FAILED, not SKIPPED - Add explicit opt-in skip via SKIP_GREMLIN_TESTS env variable - Document Docker-based local setup in inline comments Fixes apache#327 Related: apache#325, apache#320 Signed-off-by: Muawiya-contact <contactmuawia@gmail.com>
Contributor
Author
|
Hey @imbajin 👋 PR #336 is up for #327 — one file changed, small and focused. Quick recap of what's in it:
Ready for your review whenever you get a chance! 🙏 |
Contributor
There was a problem hiding this comment.
Pull request overview
Removes the silent-skip connectivity probe from TestGremlin.setUpClass so that Gremlin endpoint failures surface as test failures rather than skipped tests. An explicit opt-in skip mechanism is added via the SKIP_GREMLIN_TESTS environment variable, and the accompanying unit tests in TestGremlinSetupBehavior are updated to reflect the new behavior.
Changes:
- Drop the
try/except NotFoundErrorprobe that auto-skipped all Gremlin tests when the endpoint was unreachable. - Add
SKIP_GREMLIN_TESTS=trueenv-var opt-in path that raisesunittest.SkipTest. - Rewrite/extend behavior tests: rename the old "skips on 404" test to "reraises probe errors" and add a new test for the env-var skip path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+128
to
+139
| def test_set_up_class_reraises_probe_errors(self): | ||
| # When the gremlin client raises NotFoundError during operations, | ||
| # do not silently skip — surface the error so tests fail. | ||
| with mock.patch(f"{TestGremlin.__module__}.ClientUtils") as client_utils_cls: | ||
| client = client_utils_cls.return_value | ||
| client.gremlin = mock.Mock() | ||
| client.gremlin.exec.side_effect = NotFoundError("404 Not Found") | ||
|
|
||
| TestGremlin.setUpClass() | ||
| with self.assertRaises(NotFoundError): | ||
| TestGremlin.setUpClass() | ||
|
|
||
| self.assertTrue(TestGremlin.skip_gremlin_tests) | ||
| self.assertFalse(TestGremlin.skip_gremlin_tests) |
Comment on lines
+147
to
+152
| os.environ["SKIP_GREMLIN_TESTS"] = "true" | ||
| try: | ||
| with self.assertRaises(unittest.SkipTest): | ||
| TestGremlin.setUpClass() | ||
| finally: | ||
| os.environ.pop("SKIP_GREMLIN_TESTS", None) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Fixes the silent-skip anti-pattern in
test_gremlin.py— previously, if the Gremlin endpoint was down, all 6 tests would silently show as SKIPPED in CI instead of FAILED, hiding real regressions.Fixes #327 · Related: #325, #320
The problem
Any connectivity issue would silently swallow failures and mark tests as skipped. A broken endpoint would look green in CI. Not good.
The fix
setUpClassRunning locally
Test results
Files changed
Only one file touched:
hugegraph-python-client/src/tests/api/test_gremlin.py