File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 20
20
import requests
21
21
from hsfs .client .base import Client
22
22
from hsfs .client .exceptions import RestAPIError
23
+ from tests .util import changes_environ
23
24
24
25
25
26
class TestBaseClient :
27
+ @changes_environ
26
28
def test_valid_token_no_retires (self , mocker ):
27
29
# Arrange
28
30
os .environ [Client .REST_ENDPOINT ] = "True"
@@ -48,6 +50,7 @@ def test_valid_token_no_retires(self, mocker):
48
50
# Assert
49
51
assert spy_retry_token_expired .call_count == 0
50
52
53
+ @changes_environ
51
54
def test_invalid_token_retires (self , mocker ):
52
55
# Arrange
53
56
os .environ [Client .REST_ENDPOINT ] = "True"
@@ -77,6 +80,7 @@ def test_invalid_token_retires(self, mocker):
77
80
# Assert
78
81
assert spy_retry_token_expired .call_count == 10
79
82
83
+ @changes_environ
80
84
def test_invalid_token_retires_backoff_break (self , mocker ):
81
85
# Arrange
82
86
os .environ [Client .REST_ENDPOINT ] = "True"
Original file line number Diff line number Diff line change
1
+ #
2
+ # Copyright 2024 Hopsworks AB
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ import os
18
+ from functools import wraps
19
+
20
+
21
+ def changes_environ (f ):
22
+ @wraps (f )
23
+ def g (* args , ** kwds ):
24
+ old_environ = os .environ .copy ()
25
+ try :
26
+ return f (* args , ** kwds )
27
+ finally :
28
+ os .environ .clear ()
29
+ os .environ .update (old_environ )
30
+
31
+ return g
You can’t perform that action at this time.
0 commit comments