Skip to content

Fix functional tests failed (android, push_file) - #375

Merged
ki4070ma merged 9 commits into
appium:masterfrom
ki4070ma:fix-push-file-test
May 14, 2019
Merged

ki4070ma merged 9 commits into
appium:masterfrom
ki4070ma:fix-push-file-test

Conversation

@ki4070ma

Copy link
Copy Markdown
Collaborator

For #373

Results

➜  android git:(fix-push-file-test) ✗ python2 remote_fs_tests.py         
test_pull_folder (__main__.RemoteFsTests) ... ok
test_push_file_with_src_path (__main__.RemoteFsTests) ... ok
test_push_pull_file (__main__.RemoteFsTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 73.231s

OK
➜  android git:(fix-push-file-test) ✗ python3 remote_fs_tests.py 
test_pull_folder (__main__.RemoteFsTests) ... ok
test_push_file_with_src_path (__main__.RemoteFsTests) ... ok
test_push_pull_file (__main__.RemoteFsTests) ... ok

----------------------------------------------------------------------
Ran 3 tests in 83.874s

OK

self.driver.quit()

# remove zipped file from `test_pull_folder`
if hasattr(self, 'zipfilename') and os.path.isfile(self.zipfilename):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if os.path.exists(getattr(self, 'zipfilename', ''))


folder = self.driver.pull_folder(path)

# python doesn't have any functionality for unzipping streams

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about StringIO?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I didn't know StringIO, it's super cool.
But for here, I couldn't create zipfile object(here is myzip) with StringIO object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks so much, I did.
(I didn't take care of decoding for zipfile data...)

self.assertEqual(data, data_ret)

def test_pull_folder(self):
string_data = b'random string data %d' % random.randint(0, 1000)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use '{}'.format(var) for formatting. After dropping python2 support I would use f'{var}' format

self.assertEqual(original_data, new_data)


if __name__ == "__main__":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

' (single quote) instead of " in this file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes.

I'll replace it in all cases at this PR.


folder = self.driver.pull_folder(dest_dir)

filelist = ZipFile(BytesIO(base64.b64decode(folder))).namelist()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we use ZipFile instance with with operator ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes!

@ki4070ma
ki4070ma merged commit 89f9979 into appium:master May 14, 2019
@ki4070ma
ki4070ma deleted the fix-push-file-test branch May 14, 2019 14:15
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

Successfully merging this pull request may close these issues.

3 participants