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

test: stabilize tar extraction and iOS lifecycle tests by owenthcarey · Pull Request #110 · pythonnative/pythonnative · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .swift  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ final class PNLifecycleTests: XCTestCase {
wait(for: [ready], timeout: 15)
window.layoutIfNeeded()
}
/// Waits for a UIKit transition's end state rather than a fixed delay,
/// because presentation and dismissal take longer on a loaded simulator.
private func settle(until condition: @escaping () -> Bool, _ description: String) {
let done = expectation(for: NSPredicate { _, _ in condition() }, evaluatedWith: nil)
done.expectationDescription = description
wait(for: [done], timeout: 15)
window.layoutIfNeeded()
}
override func tearDown() {
window?.isHidden = true
window?.rootViewController = nil
Expand Down Expand Up @@ -96,14 +104,14 @@ final class PNLifecycleTests: XCTestCase {
XCTAssertTrue(navigation.topViewController?.navigationItem.rightBarButtonItem?.customView === PNViewRegistry.shared.view(for: 823))
apply([["c", 825, "Screen", ["title": "Compose", "presentation": "modal", "gesture_enabled": false, "animation": "none", "flex": 1]],
["i", 821, 825, 1]])
settle()
settle(until: { navigation.presentedViewController != nil }, "modal is presented")
let modal = try XCTUnwrap(navigation.presentedViewController as? UINavigationController)
XCTAssertEqual(modal.topViewController?.title, "Compose")
XCTAssertTrue(modal.isModalInPresentation)
XCTAssertEqual(navigation.viewControllers.count, 1)
XCTAssertTrue(PNViewRegistry.shared.view(for: 825)?.window === window)
apply([["d", 825]])
settle()
settle(until: { navigation.presentedViewController == nil }, "modal is dismissed")
XCTAssertNil(navigation.presentedViewController)
XCTAssertTrue(PNViewRegistry.shared.view(for: 822)?.window === window)
apply([["d", 824], ["d", 823]])
Expand Down
9 changes: 8 additions & 1 deletion tests/project/test_runtime_assets.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,15 @@ def test_safe_extract_rechecks_paths_after_creating_links(tmp_path: Path) -> Non
_add_link(tar, "alias", ".")
_add_file(tar, "alias/../outside_target/payload.txt")

with pytest.raises(tarfile.OutsideDestinationError):
# CPython's data filter either refuses the member (3.14.7 and earlier)
# or resolves its path inside dest (3.14.8 and later). Both are safe;
# what matters is that nothing lands outside dest.
try:
runtime_assets._safe_extract(tar_path, dest)
except tarfile.OutsideDestinationError:
pass
else:
assert (dest / "outside_target" / "payload.txt").is_file()

assert (dest / "alias").is_symlink()
assert list(outside.iterdir()) == []
Expand Down
Loading

Back | FazBrowse Home | New Git URL