From 9b4a7a02c55aa5ced0c9f21c642b6ee6a17540b7 Mon Sep 17 00:00:00 2001 From: generatedunixname647790274085263 Date: Tue, 28 May 2024 06:36:38 -0700 Subject: [PATCH] Fix silently skipped async tests (idb) Summary: When using `unittest.TestCase`, any coroutines that look like test cases won't be awaited properly, causing the test to pass immediately. This diff fixes these test cases by switching to `unittest.IsolatedAsyncioTestCase` which will start properly running these tests. I fully expect red signal on this diff, but will still land it, because a failing test is better than a silently skipped one. This diff was produced by: ``` sl go D57273213 cd fbcode arc lint --take FIXIT --paths-cmd 'hg files -I "**/*.py" | grep test' -a HG: manually revert unrelated fixit changes sl st | awk '{print $2}' | xargs pylot run fbcode//python/libcst/ codemod ensure_import_present.EnsureImportPresentCommand --module unittest --entity IsolatedAsyncioTestCase sl st | awk '{print $2}' | xargs pylot run fbcode//python/libcst/ codemod remove_unused_imports.RemoveUnusedImportsWithGlean HG: manually add back these unused imports unrelated to this change: P1370679492 HG: split the diff per oncall ./scripts/zsol/split.sh ``` Reviewed By: Nekitosss Differential Revision: D57771323 fbshipit-source-id: efb6632235e6be396fdddace969e9c480f7aea53 --- idb/grpc/tests/xctest_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idb/grpc/tests/xctest_tests.py b/idb/grpc/tests/xctest_tests.py index 42b5d9b1b..c0c43c1a7 100644 --- a/idb/grpc/tests/xctest_tests.py +++ b/idb/grpc/tests/xctest_tests.py @@ -9,12 +9,12 @@ import os.path import plistlib import tempfile -from unittest import TestCase +from unittest import IsolatedAsyncioTestCase from idb.grpc.xctest import extract_paths_from_xctestrun -class XCTestsTestCase(TestCase): +class XCTestsTestCase(IsolatedAsyncioTestCase): async def test_extract_paths_from_xctestrun(self) -> None: with tempfile.TemporaryDirectory() as tmp_dir: file_path = os.path.join(tmp_dir, "test.plist")