Skip to content

Commit 724735e

Browse files
committed
Fix test and format
1 parent 5bda458 commit 724735e

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

ppadb/device.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ def pull(self, src, dest):
8585
dest = Path(dest)
8686

8787
dir_string = "IS_DIR"
88-
res = self.shell(f"[ -d \"{src}\" ] && echo {dir_string}")
88+
res = self.shell(f'[ -d "{src}" ] && echo {dir_string}')
8989
if dir_string in res:
9090
# Get all files in the dir
9191
# Pull each
9292
dest.mkdir(exist_ok=True)
93-
cmd = f"ls -1a \"{src}\""
93+
cmd = f'ls -1a "{src}"'
9494
res = self.shell(cmd)
9595
contents_list = res.split("\n")
9696
contents_list = [
@@ -102,7 +102,7 @@ def pull(self, src, dest):
102102
self.pull(element_src, element_dest)
103103
else:
104104
file_string = "IS_FILE"
105-
res = self.shell(f"[ -f \"{src}\" ] && echo {file_string}")
105+
res = self.shell(f'[ -f "{src}" ] && echo {file_string}')
106106
if file_string not in res:
107107
raise FileNotFoundError(f"Cannot find {src} on device")
108108
self._pull(str(src), str(dest))

ppadb/device_async.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ async def pull(self, src, dest):
7070
dest = Path(dest)
7171

7272
dir_string = "IS_DIR"
73-
res = await self.shell(f"[ -d \"{src}\" ] && echo {dir_string}")
73+
res = await self.shell(f'[ -d "{src}" ] && echo {dir_string}')
7474
if dir_string in res:
7575
# Get all files in the dir
7676
# Pull each
7777
dest.mkdir(exist_ok=True)
78-
cmd = f"ls -1a \"{src}\""
78+
cmd = f'ls -1a "{src}"'
7979
res = await self.shell(cmd)
8080
contents_list = res.split("\n")
8181
contents_list = [
@@ -87,7 +87,7 @@ async def pull(self, src, dest):
8787
await self.pull(element_src, element_dest)
8888
else:
8989
file_string = "IS_FILE"
90-
res = await self.shell(f"[ -f \"{src}\" ] && echo {file_string}")
90+
res = await self.shell(f'[ -f "{src}" ] && echo {file_string}')
9191
if file_string not in res:
9292
raise FileNotFoundError(f"Cannot find {src} on device")
9393
await self._pull(str(src), str(dest))

test/test_device.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def test_filepaths():
192192
"toplevel/subdir1/test4.txt",
193193
"toplevel/subdir1/subdir2/test5.txt",
194194
"toplevel/subdir1/subdir2/test6.txt",
195-
"toplevel/subdir1/subdir2/file name.txt"
195+
"toplevel/subdir1/subdir2/file name.txt",
196196
]
197197
yield filepaths
198198

@@ -203,7 +203,7 @@ def populated_device(device, test_filepaths):
203203

204204
device.shell(f"mkdir -p /data/local/tmp/{dirpath}")
205205
for path in test_filepaths:
206-
device.shell(f"echo \"{path}\" > \"/data/local/tmp/{path}\"")
206+
device.shell(f'echo "{path}" > "/data/local/tmp/{path}"')
207207

208208
yield device
209209

@@ -215,6 +215,7 @@ def working_dir():
215215
with tempfile.TemporaryDirectory() as f:
216216
yield pathlib.Path(f)
217217

218+
218219
def test_pull_file(populated_device, working_dir):
219220
populated_device.pull(
220221
"/data/local/tmp/toplevel/test1.txt", working_dir / "test1.txt"
@@ -223,13 +224,15 @@ def test_pull_file(populated_device, working_dir):
223224
assert dest_path.is_file()
224225
assert dest_path.read_text() == "toplevel/test1.txt\n"
225226

227+
226228
def test_pull_file_with_space(populated_device, working_dir):
227229
dest_path = working_dir / "file name.txt"
228230
populated_device.pull(
229-
"/data/local/tmp/toplevel/subdir1/subdir2/file name.txt", dest_path
231+
"/data/local/tmp/toplevel/subdir1/subdir2/file name.txt", dest_path
230232
)
231233
assert dest_path.is_file()
232-
assert dest_path.read_text() == "toplevel/subdir1/subdir2/file name.txt"
234+
assert dest_path.read_text() == "toplevel/subdir1/subdir2/file name.txt\n"
235+
233236

234237
def test_pull_dir(populated_device, working_dir):
235238
populated_device.pull(

0 commit comments

Comments
 (0)