chore: clean environment for errorreporting tests#16736
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the unit tests for the Error Reporting client by clearing environment variables during the test_ctor_defaults test case to ensure isolation from the host system. The review feedback suggests applying the environment clearing decorator at the class level rather than to a single method to improve maintainability and ensure consistency across all tests in the suite.
| self.assertEqual(len(positional), 1) | ||
| return positional[0] | ||
|
|
||
| @mock.patch.dict(os.environ, clear=True) |
There was a problem hiding this comment.
The pull request title mentions cleaning the environment for 'tests' (plural), but this decorator is only applied to test_ctor_defaults. If other tests in this class also require a clean environment to ensure isolation from the host system, it would be more maintainable and consistent to apply the @mock.patch.dict(os.environ, clear=True) decorator at the class level instead of repeating it for individual test methods. This aligns with the principle of applying configuration changes consistently across relevant tests.
References
- Changes to configurations should be applied consistently across all relevant parts of the codebase.
clean environment for errorreporting tests