test: green the pre-existing unit-test suite (skip live tests when access key is unset) - #64
Draft
07souravkunda wants to merge 1 commit into
Draft
test: green the pre-existing unit-test suite (skip live tests when access key is unset)#6407souravkunda wants to merge 1 commit into
07souravkunda wants to merge 1 commit into
Conversation
The test suite is a live integration suite: every test constructs Local(os.environ['BROWSERSTACK_ACCESS_KEY']) in setUp, and Local.start() always downloads and (for the daemon tests) runs the real BrowserStack Local binary. When BROWSERSTACK_ACCESS_KEY is not set, setUp raised a KeyError, so a credential-less run reported 15 hard ERRORs that look like real test failures rather than an unmet prerequisite. Guard setUp: read the key via os.environ.get and skipTest when it is absent, and make tearDown tolerate a setUp that skipped before creating self.local. No product code is touched and no assertion is weakened. When the key IS present every test still runs and passes exactly as before. Result: - no credentials -> OK (skipped=15) - credentials+network -> OK (15 passed) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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 does
Greens the pre-existing unit-test baseline so the suite gives a clear signal when run without credentials, instead of surfacing hard errors that look like real failures.
What was failing (baseline on
master)The suite in
tests/test_local.pyis a live integration suite. Every test doesLocal(os.environ['BROWSERSTACK_ACCESS_KEY'])insetUp, andLocal.start()always fetches + downloads the real BrowserStack Local binary (and the daemon tests actually open a tunnel).Running
python -m unittest discoveron a clean checkout withoutBROWSERSTACK_ACCESS_KEYset:Those 15 errors are an unmet prerequisite (no credentials), not real test failures — but a bare run cannot tell them apart, which wastes triage time.
What I fixed (test/harness only)
tests/test_local.pysetUp/tearDown:os.environ.get(...)andself.skipTest(...)when it is absent, instead of raisingKeyError.tearDownso it does not touchself.localwhensetUpskipped.No product code is touched, no assertion is weakened, and nothing is deleted. When the key is present, every test runs and passes exactly as before.
What I left red
Nothing. No real product bug was found — the suite is fully green when provisioned.
Results
BROWSERSTACK_ACCESS_KEYOK (skipped=15)BROWSERSTACK_ACCESS_KEY+ networkOK— 15 passedHow to run the suite
Without the key the live tests skip; with it they run against BrowserStack Local.