FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: stabilize tar extraction and iOS lifecycle tests (#110) · pythonnative/pythonnative@444637a · GitHub

Commit 444637a

Browse files
authored
test: stabilize tar extraction and iOS lifecycle tests (#110)
1 parent 6dfaebc commit 444637a

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎src/pythonnative/native/ios/Tests/PythonNativeKitTests/PNLifecycleTests.swift‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ final class PNLifecycleTests: XCTestCase {
2020
wait(for: [ready], timeout: 15)
2121
window.layoutIfNeeded()
2222
}
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+
}
2331
override func tearDown() {
2432
window?.isHidden = true
2533
window?.rootViewController = nil
@@ -96,14 +104,14 @@ final class PNLifecycleTests: XCTestCase {
96104
XCTAssertTrue(navigation.topViewController?.navigationItem.rightBarButtonItem?.customView === PNViewRegistry.shared.view(for: 823))
97105
apply([["c", 825, "Screen", ["title": "Compose", "presentation": "modal", "gesture_enabled": false, "animation": "none", "flex": 1]],
98106
["i", 821, 825, 1]])
99-
settle()
107+
settle(until: { navigation.presentedViewController != nil }, "modal is presented")
100108
let modal = try XCTUnwrap(navigation.presentedViewController as? UINavigationController)
101109
XCTAssertEqual(modal.topViewController?.title, "Compose")
102110
XCTAssertTrue(modal.isModalInPresentation)
103111
XCTAssertEqual(navigation.viewControllers.count, 1)
104112
XCTAssertTrue(PNViewRegistry.shared.view(for: 825)?.window === window)
105113
apply([["d", 825]])
106-
settle()
114+
settle(until: { navigation.presentedViewController == nil }, "modal is dismissed")
107115
XCTAssertNil(navigation.presentedViewController)
108116
XCTAssertTrue(PNViewRegistry.shared.view(for: 822)?.window === window)
109117
apply([["d", 824], ["d", 823]])

‎tests/project/test_runtime_assets.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,15 @@ def test_safe_extract_rechecks_paths_after_creating_links(tmp_path: Path) -> Non
209209
_add_link(tar, "alias", ".")
210210
_add_file(tar, "alias/../outside_target/payload.txt")
211211

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:
213216
runtime_assets._safe_extract(tar_path, dest)
217+
except tarfile.OutsideDestinationError:
218+
pass
219+
else:
220+
assert (dest / "outside_target" / "payload.txt").is_file()
214221

215222
assert (dest / "alias").is_symlink()
216223
assert list(outside.iterdir()) == []

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL