| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,14 @@ final class PNLifecycleTests: XCTestCase { | |||
| 20 | 20 | wait(for: [ready], timeout: 15) | |
| 21 | 21 | window.layoutIfNeeded() | |
| 22 | 22 | } | |
| 23 | + /// Waits for a UIKit transition's end state rather than a fixed delay, | ||
| 24 | + /// because presentation and dismissal take longer on a loaded simulator. | ||
| 25 | + private func settle(until condition: @escaping () -> Bool, _ description: String) { | ||
| 26 | + let done = expectation(for: NSPredicate { _, _ in condition() }, evaluatedWith: nil) | ||
| 27 | + done.expectationDescription = description | ||
| 28 | + wait(for: [done], timeout: 15) | ||
| 29 | + window.layoutIfNeeded() | ||
| 30 | + } | ||
| 23 | 31 | override func tearDown() { | |
| 24 | 32 | window?.isHidden = true | |
| 25 | 33 | window?.rootViewController = nil | |
@@ -96,14 +104,14 @@ final class PNLifecycleTests: XCTestCase { | |||
| 96 | 104 | XCTAssertTrue(navigation.topViewController?.navigationItem.rightBarButtonItem?.customView === PNViewRegistry.shared.view(for: 823)) | |
| 97 | 105 | apply([["c", 825, "Screen", ["title": "Compose", "presentation": "modal", "gesture_enabled": false, "animation": "none", "flex": 1]], | |
| 98 | 106 | ["i", 821, 825, 1]]) | |
| 99 | - settle() | ||
| 107 | + settle(until: { navigation.presentedViewController != nil }, "modal is presented") | ||
| 100 | 108 | let modal = try XCTUnwrap(navigation.presentedViewController as? UINavigationController) | |
| 101 | 109 | XCTAssertEqual(modal.topViewController?.title, "Compose") | |
| 102 | 110 | XCTAssertTrue(modal.isModalInPresentation) | |
| 103 | 111 | XCTAssertEqual(navigation.viewControllers.count, 1) | |
| 104 | 112 | XCTAssertTrue(PNViewRegistry.shared.view(for: 825)?.window === window) | |
| 105 | 113 | apply([["d", 825]]) | |
| 106 | - settle() | ||
| 114 | + settle(until: { navigation.presentedViewController == nil }, "modal is dismissed") | ||
| 107 | 115 | XCTAssertNil(navigation.presentedViewController) | |
| 108 | 116 | XCTAssertTrue(PNViewRegistry.shared.view(for: 822)?.window === window) | |
| 109 | 117 | apply([["d", 824], ["d", 823]]) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -209,8 +209,15 @@ def test_safe_extract_rechecks_paths_after_creating_links(tmp_path: Path) -> Non | |||
| 209 | 209 | _add_link(tar, "alias", ".") | |
| 210 | 210 | _add_file(tar, "alias/../outside_target/payload.txt") | |
| 211 | 211 | ||
| 212 | - with pytest.raises(tarfile.OutsideDestinationError): | ||
| 212 | + # CPython's data filter either refuses the member (3.14.7 and earlier) | ||
| 213 | + # or resolves its path inside dest (3.14.8 and later). Both are safe; | ||
| 214 | + # what matters is that nothing lands outside dest. | ||
| 215 | + try: | ||
| 213 | 216 | runtime_assets._safe_extract(tar_path, dest) | |
| 217 | + except tarfile.OutsideDestinationError: | ||
| 218 | + pass | ||
| 219 | + else: | ||
| 220 | + assert (dest / "outside_target" / "payload.txt").is_file() | ||
| 214 | 221 | ||
| 215 | 222 | assert (dest / "alias").is_symlink() | |
| 216 | 223 | assert list(outside.iterdir()) == [] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments