Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipes tests enhancements #1984

Merged
merged 3 commits into from
Sep 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions tests/recipes/recipe_lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class BaseTestForMakeRecipe(RecipeCtx):
"""

recipe_name = None
recipes = ["python3", "kivy"]
recipe_build_order = ["hostpython3", "python3", "sdl2", "kivy"]
expected_compiler = (
"{android_ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"
)
Expand All @@ -26,13 +24,13 @@ class BaseTestForMakeRecipe(RecipeCtx):
This must be a dictionary containing pairs of key (env var) and value.
"""

def __new__(cls, *args):
obj = super().__new__(cls)
if obj.recipe_name is not None:
print(f"We are testing recipe: {obj.recipe_name}")
obj.recipes.append(obj.recipe_name)
obj.recipe_build_order.insert(1, obj.recipe_name)
return obj
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.recipes = ["python3", "kivy", self.recipe_name]
self.recipe_build_order = [
"hostpython3", self.recipe_name, "python3", "sdl2", "kivy"
]
print(f"We are testing recipe: {self.recipe_name}")

@mock.patch("pythonforandroid.recipe.Recipe.check_recipe_choices")
@mock.patch("pythonforandroid.build.ensure_dir")
Expand Down
2 changes: 1 addition & 1 deletion tests/recipes/test_gevent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from mock import patch
from unittest.mock import patch
from tests.recipes.recipe_ctx import RecipeCtx


Expand Down
2 changes: 0 additions & 2 deletions tests/recipes/test_icu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class TestIcuRecipe(RecipeCtx, unittest.TestCase):
"""

recipe_name = "icu"
recipes = ["python3", "kivy", "icu"]
recipe_build_order = ["hostpython3", "icu", "python3", "sdl2", "kivy"]

def test_url(self):
self.assertTrue(self.recipe.versioned_url.startswith("http"))
Expand Down
9 changes: 0 additions & 9 deletions tests/recipes/test_pyicu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ class TestPyIcuRecipe(RecipeCtx, unittest.TestCase):
An unittest for recipe :mod:`~pythonforandroid.recipes.pyicu`
"""
recipe_name = "pyicu"
recipes = ["python3", "kivy", "pyicu"]
recipe_build_order = [
"hostpython3",
"icu",
"python3",
"sdl2",
"pyicu",
"kivy",
]

@mock.patch("pythonforandroid.recipe.Recipe.check_recipe_choices")
@mock.patch("pythonforandroid.build.ensure_dir")
Expand Down
2 changes: 1 addition & 1 deletion tests/recipes/test_reportlab.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import unittest
from mock import patch
from unittest.mock import patch
from tests.recipes.recipe_ctx import RecipeCtx
from pythonforandroid.util import ensure_dir

Expand Down
8 changes: 1 addition & 7 deletions tests/test_archs.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import os
import unittest
from os import environ

try:
from unittest import mock
except ImportError:
# `Python 2` or lower than `Python 3.3` does not
# have the `unittest.mock` module built-in
import mock
from unittest import mock

from pythonforandroid.bootstrap import Bootstrap
from pythonforandroid.distribution import Distribution
Expand Down
7 changes: 1 addition & 6 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
import sh
import unittest

try:
from unittest import mock
except ImportError:
# `Python 2` or lower than `Python 3.3` does not
# have the `unittest.mock` module built-in
import mock
from unittest import mock
from pythonforandroid.bootstrap import (
_cmp_bootstraps_by_priority, Bootstrap, expand_dependencies,
)
Expand Down
7 changes: 1 addition & 6 deletions tests/test_build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import unittest
from unittest import mock

try:
from unittest import mock
except ImportError:
# `Python 2` or lower than `Python 3.3` does not
# have the `unittest.mock` module built-in
import mock
from pythonforandroid.build import run_pymodules_install


Expand Down
7 changes: 1 addition & 6 deletions tests/test_distribution.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import os
import json
import unittest
from unittest import mock

try:
from unittest import mock
except ImportError:
# `Python 2` or lower than `Python 3.3` does not
# have the `unittest.mock` module built-in
import mock
from pythonforandroid.bootstrap import Bootstrap
from pythonforandroid.distribution import Distribution
from pythonforandroid.recipe import Recipe
Expand Down
2 changes: 1 addition & 1 deletion tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pythonforandroid.util import BuildInterruptingException
from itertools import product

import mock
from unittest import mock
import pytest

ctx = Context()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from mock import MagicMock
from unittest.mock import MagicMock
from pythonforandroid import logger


Expand Down
2 changes: 1 addition & 1 deletion tests/test_pythonpackage_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
while the other additional ones aren't (for build time reasons).
"""

import mock
import os
import pytest
import shutil
import sys
import subprocess
import tempfile
import textwrap
from unittest import mock

from pythonforandroid.pythonpackage import (
_extract_info_from_package,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import types
import unittest
import warnings
import mock
from unittest import mock
from backports import tempfile
from pythonforandroid.build import Context
from pythonforandroid.recipe import Recipe, import_recipe
Expand Down
2 changes: 1 addition & 1 deletion tests/test_toolchain.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io
import sys
import pytest
import mock
from unittest import mock
from pythonforandroid.recipe import Recipe
from pythonforandroid.toolchain import ToolchainCL
from pythonforandroid.util import BuildInterruptingException
Expand Down
7 changes: 1 addition & 6 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import os
import types
import unittest
from unittest import mock

try:
from unittest import mock
except ImportError:
# `Python 2` or lower than `Python 3.3` does not
# have the `unittest.mock` module built-in
import mock
from pythonforandroid import util


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ basepython = python3

[testenv]
deps =
mock
py27: mock
pytest
virtualenv
py3: coveralls
Expand Down