Skip to content

Commit

Permalink
After adb.pm_install is installed, delete the apk file
Browse files Browse the repository at this point in the history
adb.pm_install在安装完毕后,删除apk文件

(cherry picked from commit eb78944)
  • Loading branch information
yimelia committed Aug 19, 2021
1 parent 45e594c commit 7d77840
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions airtest/core/android/adb.py
Expand Up @@ -656,9 +656,17 @@ def pm_install(self, filepath, replace=False):
print(out)

if not replace:
self.shell(['pm', 'install', device_path])
install_cmd = ['pm', 'install', device_path]
else:
self.shell(['pm', 'install', '-r', device_path])
install_cmd = ['pm', 'install', '-r', device_path]

try:
self.shell(install_cmd)
except:
raise
finally:
# delete apk file
self.shell("rm " + device_path)

def uninstall_app(self, package):
"""
Expand Down
5 changes: 5 additions & 0 deletions tests/test_adb.py
Expand Up @@ -178,6 +178,11 @@ def test_pm_install(self):
self.adb.pm_install(APK)
self.assertIn(PKG, self.adb.list_app())

# 安装完毕后,验证apk文件是否已删除
tmpdir = "/data/local/tmp"
tmp_files = self.adb.shell("ls " + tmpdir)
self.assertNotIn(os.path.basename(APK), tmp_files, "The apk file in /data/local/tmp is not deleted!")

self.adb.pm_uninstall(PKG)
self.assertNotIn(PKG, self.adb.list_app())

Expand Down

0 comments on commit 7d77840

Please sign in to comment.