For scenario/recording tests, keep behavior deterministic between record and replay, and ensure assertions cover defaults, required inputs, and optional fields.
Apply these rules:
Example (live-only polling adapter pattern):
def cmd(self, command, checks=None, expect_failure=False):
if self.is_live and os.environ.get('AZURE_CLI_TEST_RETRY_PROVISIONING_CHECK') == 'true':
return self._cmd_with_retry(command, checks, expect_failure)
# replay path uses normal ScenarioTest.cmd so it matches the cassette
return super().cmd(command, checks=checks, expect_failure=expect_failure)
If a test can’t be made deterministic (e.g., it generates a new resource name each run), mark it @live_only() and remove the stale recordings rather than trying to force replay to match changing values.