Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


import unittest
import os

import mock

Expand Down Expand Up @@ -51,6 +52,7 @@ def _get_report_payload(self, error_api):
self.assertEqual(len(positional), 1)
return positional[0]

@mock.patch.dict(os.environ, clear=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. Changes to configurations should be applied consistently across all relevant parts of the codebase.

@mock.patch("google.cloud.client._determine_default_project")
def test_ctor_defaults(self, default_mock):
from google.api_core.client_info import ClientInfo
Expand Down
Loading