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

Fixes test_p4a_recommended_android_ndk_found() mocking #983

Merged
merged 1 commit into from
Oct 5, 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
15 changes: 7 additions & 8 deletions tests/test_buildozer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
from six import StringIO
import tempfile

import mock
try:
from unittest import mock # Python 3
except ImportError:
import mock # Python 2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you guys like it this way, so I reintroduced it 😄


from buildozer.targets.android import (
TargetAndroid, DEFAULT_ANDROID_NDK_VERSION, MSG_P4A_RECOMMENDED_NDK_ERROR
Expand Down Expand Up @@ -227,14 +230,10 @@ def test_p4a_recommended_android_ndk_found(
):
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)
Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically pytest makes it possible to see exact result of failing comparison. That way we don't need to debug print around in Travis 😉


[testenv:pep8]
deps = flake8
Expand Down