Skip to content

Commit

Permalink
Update response_test.py (#311)
Browse files Browse the repository at this point in the history
refactor with With statement to open file to make code more Pythonic
  • Loading branch information
anonymousdouble authored Jun 22, 2024
1 parent e382d1f commit 234bb6a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/src/OneLogin/saml2_tests/response_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ class OneLogin_Saml2_Response_Test(unittest.TestCase):
def loadSettingsJSON(self, name='settings1.json'):
filename = join(self.settings_path, name)
if exists(filename):
stream = open(filename, 'r')
settings = json.load(stream)
stream.close()
return settings
with open(filename, 'r') as stream:
settings = json.load(stream)
return settings

def file_contents(self, filename):
f = open(filename, 'r')
content = f.read()
f.close()
return content
with open(filename, 'r') as f:
content = f.read()
return content

def get_request_data(self):
return {
Expand Down

0 comments on commit 234bb6a

Please sign in to comment.