Open TestNovice opened 1 week ago
import hashlib import pytest def encrypt_password(password): """ 使用MD5算法对密码进行加密 :param password: 明文密码字符串 :return: 加密后的MD5值,以32位小写十六进制字符串表示 """ md5_hash = hashlib.md5() # 注意:hashlib.md5()接收的是字节类型,因此如果password是字符串,需要先转换为字节 md5_hash.update(password.encode('utf-8')) return md5_hash.hexdigest() param_data = { "username": "admin", "password": "123456" } @pytest.mark.flaky(reruns=2, reruns_delay=2) @pytest.mark.parametrize("source_data", [param_data]) def test_sum_data(source_data): source_data["password"] = encrypt_password(source_data["password"]) print("encrypt_data:", source_data) assert False
this result:
So, does re running not reinitialize some data?
Hi @TestNovice, inside the test function you are changing the values of your param_data dict. – This is the way Python works. There is no way to reinitialize the parameters of the function.
param_data
this result:![Snipaste_2024-07-05_16-24-49](https://github.com/pytest-dev/pytest-rerunfailures/assets/101795088/822d8480-832e-4c5d-b73b-5bce6d35bad9)
So, does re running not reinitialize some data?