diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index a154164b..19e5ce30 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -30,7 +30,7 @@ def save_json(req_json): The file need to be saved with one name format with the stamptime and uuid joins """ name_file = "{uuid}_{time}.json".format(uuid=req_json.get('uuid', ''), time=int(time())) - path_name = "{tmp}/{file}".format(tmp=TMP_SNAPSHOTS, file=name_file) + path_name = os.path.join(tmp=TMP_SNAPSHOTS, file=name_file) if not os.path.isdir(TMP_SNAPSHOTS): os.system('mkdir -p {}'.format(TMP_SNAPSHOTS)) diff --git a/tests/test_snapshot.py b/tests/test_snapshot.py index 290a7e76..b3157d38 100644 --- a/tests/test_snapshot.py +++ b/tests/test_snapshot.py @@ -491,7 +491,7 @@ def test_save_snapshot_in_file(): snapshot = {'software': '', 'version': '', 'uuid': ''} if files: - path_snapshot = "{dir}/{file}".format(dir=TMP_SNAPSHOTS, file=files[0]) + path_snapshot = os.path.join(dir=TMP_SNAPSHOTS, file=files[0]) file_snapshot = open(path_snapshot) snapshot = json.loads(file_snapshot.read()) file_snapshot.close() @@ -514,7 +514,7 @@ def test_backup_snapshot_with_errors(user: UserClient): files = [x for x in os.listdir(TMP_SNAPSHOTS) if uuid in x] if files: - path_snapshot = "{dir}/{file}".format(dir=TMP_SNAPSHOTS, file=files[0]) + path_snapshot = os.path.join(dir=TMP_SNAPSHOTS, file=files[0]) file_snapshot = open(path_snapshot) snapshot = json.loads(file_snapshot.read()) file_snapshot.close()