1# Copyright 2015 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5class WiFiInterfaceClaimContext(object): 6 """Context that encapsulates claiming of a wifi interface. 7 8 This context ensures that if the test fails while the interface is claimed 9 we will attempt to release it before our test exits. 10 11 """ 12 13 def __init__(self, client): 14 self._client = client 15 16 17 def __enter__(self): 18 self._client.claim_wifi_if() 19 20 21 def __exit__(self, exception, value, traceback): 22 self._client.release_wifi_if() 23