from pythonforandroid.build import Context from pythonforandroid.graph import ( fix_deplist, get_dependency_tuple_list_for_recipe, get_recipe_order_and_bootstrap, obvious_conflict_checker, ) from pythonforandroid.bootstrap import Bootstrap from pythonforandroid.recipe import Recipe from pythonforandroid.util import BuildInterruptingException from itertools import product from unittest import mock import pytest ctx = Context() name_sets = [['python3'], ['kivy']] bootstraps = [None, Bootstrap.get_bootstrap('sdl2', ctx)] valid_combinations = list(product(name_sets, bootstraps)) valid_combinations.extend( [(['python3'], Bootstrap.get_bootstrap('sdl2', ctx)), (['kivy', 'python3'], Bootstrap.get_bootstrap('sdl2', ctx)), (['flask'], Bootstrap.get_bootstrap('webview', ctx)), (['pysdl2'], None), # auto-detect bootstrap! important corner case ] ) invalid_combinations = [ [['pil', 'pillow'], None], [['pysdl2', 'genericndkbuild'], None], ] invalid_combinations_simple = list(invalid_combinations) # NOTE !! keep in mind when setting invalid_combinations_simple: # # This is used to test obvious_conflict_checker(), which only # catches CERTAIN conflicts: # # This must be a list of conflicts where the conflict is ONLY in # non-tuple/non-ambiguous dependencies, e.g.: # # dependencies_1st = ["python2", "pillow"] # dependencies_2nd = ["python3", "pillow"] # # This however won't work: # # dependencies_1st = [("python2", "python3"), "pillow"] # # (This is simply because the conflict checker doesn't resolve this to # keep the code ismple enough) def get_fake_recipe(name, depends=None, conflicts=None): recipe = mock.Mock() recipe.name = name recipe.get_opt_depends_in_list = lambda: [] recipe.get_dir_name = lambda: name recipe.depends = list(depends or []) recipe.conflicts = list(conflicts or []) return recipe def register_fake_recipes_for_test(monkeypatch, recipe_list): _orig_get_recipe = Recipe.get_recipe def mock_get_recipe(name, ctx): for recipe in recipe_list: if recipe.name == name: return recipe return _orig_get_recipe(name, ctx) # Note: staticmethod() n