Repository navigation
Conversation
Determine the destination from the local source type instead of parsing the remote Android path. This keeps extensionless files and directories with dots from being routed to the wrong location, and adds regression coverage for both cases.
There was a problem hiding this comment.
Pull request overview
This PR updates ADB.push() path resolution to avoid misclassifying remote destinations based on filename extensions (especially for extensionless files and dot-containing paths), and adds regression tests for the updated behavior.
Changes:
- Reworked
airtest.core.android.adb.ADB.push()to derive and consistently use a computeddst_pathfor cleanup, mkdir, temporary push, and final placement. - Updated temp-transfer logic to use the computed destination basename for staging.
- Added unit tests covering extensionless-file rename and directory push into a dot-containing remote path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airtest/core/android/adb.py |
Adjusts ADB.push() destination computation and temp-transfer behavior to preserve intended remote paths. |
tests/test_adb.py |
Adds regression tests for extensionless file destination preservation and dot-containing remote path handling. |
Suppressed comments (1)
airtest/core/android/adb.py:532
- When dst_path is already inside TMP_PATH (common when remote is "/data/local/tmp"), tmp_path becomes equal to dst_path. In the directory case, the subsequent cp -frp "tmp_path" "dst_parent" attempts to copy a directory into its own parent (or into itself), which can error or create unintended nested paths. Adding a fast-path when tmp_path == dst_path avoids this and also lets you simplify the redundant mv try/except.
tmp_path = f"{TMP_PATH}/{os.path.basename(dst_path)}"
try:
self.cmd(["push", local, tmp_path])
except:
self.cmd(["push", local, dst_path])
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+499
to
+507
| if src_is_file: | ||
| # A remote path without an extension is still a file when the | ||
| # local source is a file and the caller supplied a new name. | ||
| src_ext = os.path.splitext(local)[-1] | ||
| dst_ext = os.path.splitext(remote)[-1] | ||
| if dst_ext == "" and src_ext != "": | ||
| dst_path = f"{remote}/{os.path.basename(local)}" | ||
| else: | ||
| dst_path = remote |
Comment on lines
515
to
525
| try: | ||
| self.shell(f"rm -r {dst_path}") | ||
| except: | ||
| pass | ||
|
|
||
| # If the target folder has multiple levels that have never been created, try to create them | ||
| dst_parent = os.path.dirname(dst_path) | ||
| try: | ||
| self.shell(f"mkdir -p {dst_parent}") | ||
| except: | ||
| pass |
Handle trailing-slash destinations for extensionless files and pass remote paths as separate adb shell arguments. Add regression coverage for directory-style destinations while addressing the review feedback on path handling.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
Fixes #1321.
The previous implementation inspected the remote Android path with local
os.path.isfile()and used its extension to decide whether the destination was a file or directory. That could route files and directories to incorrect paths. The updated implementation derives the destination from the local source and uses the computed destination consistently for temporary transfers.Testing
python -m unittest tests.test_adb.TestADBWithoutDevice.test_push_extensionless_file_to_renamed_remote_path tests.test_adb.TestADBWithoutDevice.test_push_directory_to_remote_path_containing_dot -vpython -m compileall -q airtest testsgit diff --check