forked from browserstack/pytest-browserstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpavement.py
More file actions
37 lines (34 loc) · 1.25 KB
/
pavement.py
File metadata and controls
37 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from paver.easy import *
from paver.setuputils import setup
from multiprocess import Process
import platform
import json
setup(
name = "pytest-browserstack",
version = "0.1.0",
author = "BrowserStack",
author_email = "support@browserstack.com",
description = ("PyTest Integration with BrowserStack"),
license = "MIT",
keywords = "example selenium browserstack",
url = "https://github.com/browserstack/pytest-browserstack",
packages=['tests']
)
def run_py_test(config, task_id=0):
if platform.system() == "Windows":
sh('cmd /C "set CONFIG_FILE=config/%s.json && set TASK_ID=%s && pytest -s tests/test_%s.py --driver Browserstack"' % (config, task_id, config))
else:
sh('CONFIG_FILE=config/%s.json TASK_ID=%s pytest -s tests/test_%s.py --driver Browserstack' % (config, task_id, config))
@task
@consume_nargs(1)
def run(args):
"""Run single, local and parallel test using different config."""
jobs = []
config_file = 'config/%s.json' % (args[0])
with open(config_file) as data_file:
CONFIG = json.load(data_file)
environments = CONFIG['environments']
for i in range(len(environments)):
p = Process(target=run_py_test, args=(args[0], i))
jobs.append(p)
p.start()