Skip to content

Commit

Permalink
Fix silently skipped async tests (idb)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
generatedunixname647790274085263 authored and facebook-github-bot committed May 28, 2024
1 parent 45666c7 commit 9b4a7a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions idb/grpc/tests/xctest_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 9b4a7a0

Please sign in to comment.