Merge pull request #983 from AndreMiras/feature/minor_tests_improvements

Fixes test_p4a_recommended_android_ndk_found() mocking
This commit is contained in:
Alexander Taylor 2019-10-05 17:40:29 +01:00 committed by GitHub
commit 81c31c4d1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View file

@ -7,7 +7,10 @@ from buildozer import Buildozer, IS_PY3
from six import StringIO
import tempfile
import mock
try:
from unittest import mock # Python 3
except ImportError:
import mock # Python 2
from buildozer.targets.android import (
TargetAndroid, DEFAULT_ANDROID_NDK_VERSION, MSG_P4A_RECOMMENDED_NDK_ERROR
@ -227,14 +230,10 @@ class TestBuildozer(unittest.TestCase):
):
self.set_specfile_log_level(self.specfile.name, 1)
buildozer = Buildozer(self.specfile.name, 'android')
expected_ndk = '19b'
mock_open.side_effect = [
mock.mock_open(
read_data='RECOMMENDED_NDK_VERSION = {expected_ndk}\n'.format(
expected_ndk=expected_ndk)
).return_value
]
recommended_line = 'RECOMMENDED_NDK_VERSION = {expected_ndk}\n'.format(
expected_ndk=expected_ndk)
mock_open.return_value = StringIO(recommended_line)
ndk_version = buildozer.target.p4a_recommended_android_ndk
p4a_dir = os.path.join(
buildozer.platform_dir, buildozer.target.p4a_directory_name)

View file

@ -2,9 +2,10 @@
envlist = pep8,py27,py3
[testenv]
deps = mock
commands =
python -m unittest discover --top-level-directory=. --start-directory=tests/
deps =
mock
pytest
commands = pytest tests/
[testenv:pep8]
deps = flake8