Skip to content

fix the flaky test_exec_module_failure_case by enforcing the _cold_st… #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
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
7 changes: 6 additions & 1 deletion tests/test_cold_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

class TestColdStartTracingSetup(unittest.TestCase):
def test_initialize_cold_start_tracing(self):
cold_start._cold_start = True
cold_start.initialize_cold_start_tracing() # testing double wrapping
cold_start._cold_start = True
cold_start.initialize_cold_start_tracing()
cold_start.reset_node_stacks()
for module_name in ["ast", "dis", "inspect"]:
Expand All @@ -22,6 +24,7 @@ def test_initialize_cold_start_tracing(self):
def test_bad_importer_find_spec_attribute_error(self):
mock_importer = object() # AttributeError when accessing find_spec
meta_path.append(mock_importer)
cold_start._cold_start = True
cold_start.initialize_cold_start_tracing() # safe to call
meta_path.pop()

Expand All @@ -38,12 +41,13 @@ def find_spec(*args, **kwargs):

mock_importer.find_spec = find_spec
meta_path.append(mock_importer)
cold_start._cold_start = True
cold_start.initialize_cold_start_tracing()
self.assertFalse(mock_loader in cold_start.already_wrapped_loaders)
meta_path.pop()
os.environ["DD_COLD_START_TRACING"] = "true"

def xtest_exec_module_failure_case(self):
def test_exec_module_failure_case(self):
mock_importer = MagicMock()
mock_module_spec = MagicMock()
mock_module_spec.name = "test_name"
Expand All @@ -60,6 +64,7 @@ def find_spec(*args, **kwargs):

mock_importer.find_spec = find_spec
meta_path.insert(0, mock_importer)
cold_start._cold_start = True
cold_start.initialize_cold_start_tracing()
cold_start.reset_node_stacks()
try:
Expand Down