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

Create tests for PR fix bug when logcat value which cannot be decode to utf-8 #857

Closed
Draqun opened this issue Mar 14, 2019 · 3 comments
Closed

Comments

@Draqun
Copy link
Contributor

Draqun commented Mar 14, 2019

Create tests for fix from link below.

#856

@Draqun
Copy link
Contributor Author

Draqun commented May 27, 2019

Hi. Sadly I don't have enough skills to write tests. I don't know docker (ugly solution) and there is no requirements.txt file to build venv.
Sorry for that.

@AndreMiras
Copy link
Member

AndreMiras commented May 27, 2019

No worries, this could be tricky.
I'm actually not sure how this error you fixed happens.
Anyway for testing it I would say it should involve mocking https://docs.python.org/3/library/unittest.mock.html
The way I would have imagined it is calling Buildozer.cmd() within a mocked Popen to make sure it .stdout.read() returns a non utf-8 decodable string.
So the patching could look like this (untested):

command = 'mycommand'
kwargs = { 'show_output': True }
with mock.patch('buildozer.Popen') as m_popen:
    # the command output could be were we want to play with unicode decode errors
    m_popen().stdout.read.side_effect = [b'mycommand output']
    buildozer.cmd(command, **kwargs)

That just to give the idea.

AndreMiras added a commit to AndreMiras/buildozer that referenced this issue May 28, 2019
Also fixes stderr/stdout writing introduced in kivy#743.
@AndreMiras
Copy link
Member

I just gave it a try see #905
So yes definitely not the best use case to start playing with mocks

AndreMiras added a commit that referenced this issue May 28, 2019
…icode_decode

Unit test unicode decode on command output, fixes #857
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants