Skip to content

Commit 1327638

Browse files
authored
Merge pull request kivy#893 from inclement/new_tests
New tests
2 parents c36cf0d + 8160a6f commit 1327638

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

test_builds/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
py.test -s

test_builds/tests/test_apk.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
from pythonforandroid.toolchain import main
3+
4+
from os import path
5+
import sys
6+
7+
import pytest
8+
9+
# Set these values manually before testing (for now)
10+
ndk_dir = '/home/asandy/android/crystax-ndk-10.3.2'
11+
ndk_version='crystax-ndk-10.3.2'
12+
13+
cur_dir = path.dirname(path.abspath(__file__))
14+
testapps_dir = path.join(path.split(path.split(cur_dir)[0])[0], 'testapps')
15+
16+
orig_argv = sys.argv[:]
17+
18+
def set_argv(argv):
19+
while sys.argv:
20+
sys.argv.pop()
21+
sys.argv.append(orig_argv[0])
22+
for item in argv:
23+
sys.argv.append(item)
24+
for item in orig_argv[1:]:
25+
if item == '-s':
26+
continue
27+
sys.argv.append(item)
28+
29+
30+
argument_combinations = [{'app_dir': path.join(testapps_dir, 'testapp'),
31+
'requirements': 'python2,pyjnius,kivy',
32+
'packagename': 'p4a_test_sdl2',
33+
'bootstrap': 'sdl2',
34+
'ndk_dir': ndk_dir,
35+
'ndk_version': ndk_version},
36+
{'app_dir': path.join(testapps_dir, 'testapp'),
37+
'requirements': 'python2,pyjnius,kivy',
38+
'packagename': 'p4a_test_pygame',
39+
'bootstrap': 'pygame',
40+
'ndk_dir': ndk_dir,
41+
'ndk_version': ndk_version},
42+
{'app_dir': path.join(testapps_dir, 'testapp_flask'),
43+
'requirements': 'python2,flask,pyjnius',
44+
'packagename': 'p4a_test_flask',
45+
'bootstrap': 'webview',
46+
'ndk_dir': ndk_dir,
47+
'ndk_version': ndk_version},
48+
]
49+
50+
51+
@pytest.mark.parametrize('args', argument_combinations)
52+
def test_build_sdl2(args):
53+
54+
set_argv(('apk --requirements={requirements} --private '
55+
'{app_dir} --package=net.p4a.{packagename} --name={packagename} '
56+
'--version=0.1 --bootstrap={bootstrap} --android_api=19 '
57+
'--ndk_dir={ndk_dir} --ndk_version={ndk_version} --debug '
58+
'--permission VIBRATE '
59+
'--orientation portrait --dist_name=test-{packagename}').format(
60+
**args).split(' '))
61+
62+
print('argv are', sys.argv)
63+
64+
main()
65+

tests/test_graph.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,33 @@
1919
[(['python3crystax'], Bootstrap.get_bootstrap('sdl2', ctx)),
2020
(['kivy', 'python3crystax'], Bootstrap.get_bootstrap('sdl2', ctx))])
2121

22+
2223
@pytest.mark.parametrize('names,bootstrap', valid_combinations)
2324
def test_valid_recipe_order_and_bootstrap(names, bootstrap):
2425
get_recipe_order_and_bootstrap(ctx, names, bootstrap)
2526

2627
invalid_combinations = [[['python2', 'python3crystax'], None],
2728
[['python3'], Bootstrap.get_bootstrap('pygame', ctx)]]
2829

30+
2931
@pytest.mark.parametrize('names,bootstrap', invalid_combinations)
3032
def test_invalid_recipe_order_and_bootstrap(names, bootstrap):
3133
with pytest.raises(SystemExit):
3234
get_recipe_order_and_bootstrap(ctx, names, bootstrap)
3335

36+
3437
def test_bootstrap_dependency_addition():
3538
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
3639
ctx, ['kivy'], None)
3740
assert (('hostpython2' in build_order) or ('hostpython3' in build_order))
3841

42+
43+
def test_bootstrap_dependency_addition2():
44+
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
45+
ctx, ['kivy', 'python2'], None)
46+
assert 'hostpython2' in build_order
47+
48+
3949
if __name__ == "__main__":
40-
get_recipe_order_and_bootstrap(ctx, ['python3'], Bootstrap.get_bootstrap('sdl2', ctx))
50+
get_recipe_order_and_bootstrap(ctx, ['python3'],
51+
Bootstrap.get_bootstrap('sdl2', ctx))

0 commit comments

Comments
 (0)