Description
openedon Mar 13, 2024
As described in #22387 (comment), the value of the PYTEST_CURRENT_TEST
environment variable can vary depending on how tests are run. AzureRecordedTestCase.get_resource_name
relies on the value of this variable to produce unique resource names deterministically, which means that tests could fail in playback if run differently than when they were recorded.
If possible, it would be ideal to remove dependencies on this environment variable (pytest
's own documentation states that it shouldn't be relied on for scripting). The difficulty in doing so is that tests using AzureRecordedTestCase.get_resource_name
would have to be re-recorded. Also, we would need to find another reliable way to uniquely identify the executing test.
An alternative solution, then, would be to make sure that we consistently use what we expect the value of PYTEST_CURRENT_TEST
to be -- which should be "sdk/{service}/{package}/tests/{test_file}.py[::{TestClass}]::{test_method} (call)"