From: Kevin Zhao Date: Thu, 22 Jul 2021 06:58:20 +0000 (+0100) Subject: qa/run-tox-mgr-dashboard: Do not write to /tmp/test_sanitize_password.txt file X-Git-Tag: v16.2.8~227^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9790c7b811f3ad202132574f93cb566e9a41e254;p=ceph.git qa/run-tox-mgr-dashboard: Do not write to /tmp/test_sanitize_password.txt file To allow running multiple instances of the same tests. Fixes: https://tracker.ceph.com/issues/51792 Signed-off-by: Kevin Zhao (cherry picked from commit d04ef800abd671a564795eba198ca976619b4cc7) --- diff --git a/src/pybind/mgr/dashboard/tests/test_access_control.py b/src/pybind/mgr/dashboard/tests/test_access_control.py index 7a75bda6dd35..361f65e60dc0 100644 --- a/src/pybind/mgr/dashboard/tests/test_access_control.py +++ b/src/pybind/mgr/dashboard/tests/test_access_control.py @@ -4,6 +4,7 @@ from __future__ import absolute_import import errno import json +import tempfile import time import unittest from datetime import datetime, timedelta @@ -587,7 +588,7 @@ class AccessControlTest(unittest.TestCase, CLICommandTestMixin): def test_sanitize_password(self): self.test_create_user() password = 'myPass\\n\\r\\n' - with open('/tmp/test_sanitize_password.txt', 'w+') as pwd_file: + with tempfile.TemporaryFile(mode='w+') as pwd_file: # Add new line separators (like some text editors when a file is saved). pwd_file.write('{}{}'.format(password, '\n\r\n\n')) pwd_file.seek(0)