Skip to content

test(python-client): fix silent-skip anti-pattern in test_gremlin.py setUpClass (#327)#336

Open
Muawiya-contact wants to merge 1 commit into
apache:mainfrom
Muawiya-contact:fix/silent-skip-gremlin-setUpClass
Open

test(python-client): fix silent-skip anti-pattern in test_gremlin.py setUpClass (#327)#336
Muawiya-contact wants to merge 1 commit into
apache:mainfrom
Muawiya-contact:fix/silent-skip-gremlin-setUpClass

Conversation

@Muawiya-contact
Copy link
Copy Markdown
Contributor

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

# OLD — bad
except (ConnectionError, Timeout, HTTPError):
    raise unittest.SkipTest("Gremlin endpoint unavailable")  # hides failures!

Any connectivity issue would silently swallow failures and mark tests as skipped. A broken endpoint would look green in CI. Not good.


The fix

  • Removed the automatic connectivity probe from setUpClass
  • Failures now surface as FAILED, not SKIPPED
  • Added an explicit opt-in skip via env var for local dev:
# want to skip? opt in explicitly
export SKIP_GREMLIN_TESTS=true

Running locally

# start HugeGraph
docker run -d --name hugegraph -p 8080:8080 hugegraph/hugegraph:latest

wait ~30s, then run

python -m pytest src/tests/api/test_gremlin.py -v

cleanup

docker stop hugegraph && docker rm hugegraph


Test results

Scenario Expected
No endpoint FAILED
SKIP_GREMLIN_TESTS=true SKIPPED
Env var unset FAILED
TestGremlinSetupBehavior unit tests PASSED

Files changed

Only one file touched: hugegraph-python-client/src/tests/api/test_gremlin.py

…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>
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 18, 2026
@Muawiya-contact
Copy link
Copy Markdown
Contributor Author

Hey @imbajin 👋

PR #336 is up for #327 — one file changed, small and focused.

Quick recap of what's in it:

  • Removed the silent-skip probe from setUpClass
  • Tests now FAIL (not skip) when the endpoint is down
  • Added explicit SKIP_GREMLIN_TESTS=true opt-in as you suggested
  • Documented Docker local setup in inline comments

Ready for your review whenever you get a chance! 🙏

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NotFoundError probe that auto-skipped all Gremlin tests when the endpoint was unreachable.
  • Add SKIP_GREMLIN_TESTS=true env-var opt-in path that raises unittest.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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python-client size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] test: fix silent skip anti-pattern in test_gremlin.py setUpClass probe

2 participants