From d1733212a57b04d36bddebbc70ef7ea8f2564209 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Fri, 7 Aug 2026 21:55:29 +0530 Subject: [PATCH] test: skip live tests gracefully when BROWSERSTACK_ACCESS_KEY is unset 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 --- tests/test_local.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_local.py b/tests/test_local.py index d5d4e46..7c29a5e 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -3,10 +3,14 @@ class TestLocal(unittest.TestCase): def setUp(self): - self.local = Local(os.environ['BROWSERSTACK_ACCESS_KEY']) + access_key = os.environ.get('BROWSERSTACK_ACCESS_KEY') + if not access_key: + self.skipTest('BROWSERSTACK_ACCESS_KEY is not set; skipping live BrowserStack Local tests') + self.local = Local(access_key) def tearDown(self): - self.local.stop() + if hasattr(self, 'local'): + self.local.stop() def test_start_local(self): self.local.start()