Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3f5438

Browse files
authored
chore: throw FileNotFoundError for nonexistant files (#3014)
1 parent731b539 commitd3f5438

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

‎playwright/_impl/_set_input_files_helpers.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
importbase64
1515
importcollections.abc
1616
importos
17+
importstat
1718
frompathlibimportPath
1819
fromtypingimport (
1920
TYPE_CHECKING,
@@ -144,7 +145,8 @@ def resolve_paths_and_directory_for_input_files(
144145
local_paths:Optional[List[str]]=None
145146
local_directory:Optional[str]=None
146147
foriteminitems:
147-
ifos.path.isdir(item):
148+
item_stat=os.stat(item)# Raises FileNotFoundError if doesn't exist
149+
ifstat.S_ISDIR(item_stat.st_mode):
148150
iflocal_directory:
149151
raiseError("Multiple directories are not supported")
150152
local_directory=str(Path(item).resolve())

‎tests/sync/test_locators.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ def test_locators_should_upload_a_file(page: Page, server: Server) -> None:
327327
)
328328

329329

330+
deftest_locators_upload_nonexistant_file(page:Page,server:Server)->None:
331+
page.goto(server.PREFIX+"/input/fileupload.html")
332+
withpytest.raises(FileNotFoundError):
333+
page.locator("input[type=file]").set_input_files("nonexistant.html")
334+
335+
330336
deftest_locators_should_press(page:Page)->None:
331337
page.set_content("<input type='text' />")
332338
page.locator("input").press("h")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp