Skip to content

Commit ae9f1f3

Browse files
committed
add example script tests to conda meta.yaml
1 parent 0e82a06 commit ae9f1f3

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

meta.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ requirements:
3232
- pyee>=12,<13
3333

3434
test: # [build_platform == target_platform]
35+
files:
36+
- scripts/example_sync.py
37+
- scripts/example_async.py
3538
requires:
3639
- pip
3740
imports:
@@ -41,6 +44,8 @@ test: # [build_platform == target_platform]
4144
commands:
4245
- playwright --help
4346
- playwright install
47+
- python scripts/example_sync.py
48+
- python scripts/example_async.py
4449

4550
about:
4651
home: https://github.com/microsoft/playwright-python

scripts/example_async.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import asyncio
2+
from playwright.async_api import async_playwright
3+
4+
5+
async def main() -> None:
6+
async with async_playwright() as p:
7+
for browser_type in [p.chromium, p.firefox, p.webkit]:
8+
browser = await browser_type.launch()
9+
page = await browser.new_page()
10+
await page.goto('http://playwright.dev')
11+
await page.screenshot(path=f'example-{browser_type.name}.png')
12+
await browser.close()
13+
14+
15+
if __name__ == "__main__":
16+
asyncio.run(main())

scripts/example_sync.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from playwright.sync_api import sync_playwright
2+
3+
4+
def main() -> None:
5+
with sync_playwright() as p:
6+
for browser_type in [p.chromium, p.firefox, p.webkit]:
7+
browser = browser_type.launch()
8+
page = browser.new_page()
9+
page.goto('http://playwright.dev')
10+
page.screenshot(path=f'example-{browser_type.name}.png')
11+
browser.close()
12+
13+
14+
if __name__ == "__main__":
15+
main()

0 commit comments

Comments
 (0)