-
Notifications
You must be signed in to change notification settings - Fork 3
/
pavement.py
61 lines (54 loc) · 1.37 KB
/
pavement.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from paver.easy import *
from paver.setuputils import setup
import multiprocessing
import json
import os
setup(
name="python-behave-proverbial",
packages=['features'],
version="1.0.0",
url="https://www.lambdatest.com/",
author="Lambdatest",
description=("Behave Integration with Lambdatest"),
license="MIT",
author_email="support@lambdatest.com"
)
def run_behave_test(env, index=0):
"""
runs the individual test
:param env:
:param index:
:return:
"""
if env == "jenkins":
sh('INDEX=%s env=%s behave features/test.feature ' % (index, env,))
else:
sh('INDEX=%s env=%s behave features/test.feature ' % (index, env,))
@task
@consume_args
def run(args):
"""
runs the behave test
:return:
"""
env = args[0] if len(args) > 0 else ""
jobs = []
pool = get_pool_size()
for i in range(pool):
p = multiprocessing.Process(target=run_behave_test, args=(env, i,))
jobs.append(p)
p.start()
def get_pool_size():
"""
sets the number of parallel test
:return:
"""
if "LT_BROWSERS" in os.environ:
CONFIG = json.loads(os.environ["LT_BROWSERS"])
pool = len(CONFIG)
else:
json_file = "config/config.json"
with open(json_file) as data_file:
CONFIG = json.load(data_file)
pool = len(CONFIG)
return pool