Skip to content

Commit

Permalink
remove config that no longer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Oct 8, 2024
1 parent e7cb25f commit adbc139
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
2 changes: 0 additions & 2 deletions tests/ci_visibility/test_ci_visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ def test_civisibilitywriter_agentless_url(self):
assert dummy_writer.intake_url == "https://foo.bar"

def test_civisibilitywriter_coverage_agentless_url(self):
ddtrace.internal.ci_visibility.writer.config._ci_visibility_agentless_url = ""
with _ci_override_env(
dict(
DD_API_KEY="foobar.baz",
Expand All @@ -590,7 +589,6 @@ def test_civisibilitywriter_coverage_agentless_url(self):
_get_connection.assert_called_once_with("https://citestcov-intake.datadoghq.com", 2.0)

def test_civisibilitywriter_coverage_agentless_with_intake_url_param(self):
ddtrace.internal.ci_visibility.writer.config._ci_visibility_agentless_url = ""
with _ci_override_env(
dict(
DD_API_KEY="foobar.baz",
Expand Down
19 changes: 5 additions & 14 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def override_global_config(values):
"_trace_compute_stats",
"_obfuscation_query_string_pattern",
"global_query_string_obfuscation_disabled",
"_ci_visibility_agentless_url",
"_subexec_sensitive_user_wildcards",
"_remote_config_enabled",
"_remote_config_poll_interval",
Expand Down Expand Up @@ -195,24 +194,16 @@ def override_config(integration, values):
>>> with self.override_config('flask', dict(service_name='test-service')):
# Your test
"""
integration_config = getattr(ddtrace.config, integration)
with override_attributes(integration_config, values):
yield
options = getattr(ddtrace.config, integration)

original = dict((key, options.get(key)) for key in values.keys())

@contextlib.contextmanager
def override_attributes(obj, attributes):
# store current attributes
original_attrs = dict((key, getattr(obj, key)) for key in attributes.keys())
options.update(values)
try:
# override attributes
for key, value in attributes.items():
setattr(obj, key, value)
yield
finally:
# restore original attributes
for key, value in original_attrs.items():
setattr(obj, key, value)
options.update(original)
ddtrace.config._reset()


@contextlib.contextmanager
Expand Down

0 comments on commit adbc139

Please sign in to comment.