1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- import base64
1716import unittest
18- from zipfile import ZipFile
1917import os
20- import random
2118from time import sleep
2219from dateutil .parser import parse
2320
@@ -42,10 +39,6 @@ def setUp(self):
4239 def tearDown (self ):
4340 self .driver .quit ()
4441
45- # remove zipped file from `test_pull_folder`
46- if hasattr (self , 'zipfilename' ) and os .path .isfile (self .zipfilename ):
47- os .remove (self .zipfilename )
48-
4942 def test_screen_record (self ):
5043 self .driver .start_recording_screen (timeLimit = 10 , forcedRestart = True )
5144 sleep (10 )
@@ -99,35 +92,6 @@ def test_current_package(self):
9992 package = self .driver .current_package
10093 self .assertEqual ('com.example.android.apis' , package )
10194
102- def test_push_pull_file (self ):
103- path = '/data/local/tmp/test_push_file.txt'
104- data = b'This is the contents of the file to push to the device.'
105-
106- self .driver .push_file (path , base64 .b64encode (data ).decode ('utf-8' ))
107- data_ret = base64 .b64decode (self .driver .pull_file (path ))
108-
109- self .assertEqual (data , data_ret )
110-
111- def test_pull_folder (self ):
112- string_data = b'random string data %d' % random .randint (0 , 1000 )
113- path = '/data/local/tmp'
114-
115- self .driver .push_file (path + '/1.txt' , base64 .b64encode (string_data ).decode ('utf-8' ))
116- self .driver .push_file (path + '/2.txt' , base64 .b64encode (string_data ).decode ('utf-8' ))
117-
118- folder = self .driver .pull_folder (path )
119-
120- # python doesn't have any functionality for unzipping streams
121- # save temporary file, which will be deleted in `tearDown`
122- self .zipfilename = 'folder_%d.zip' % random .randint (0 , 1000000 )
123- with open (self .zipfilename , "wb" ) as fw :
124- fw .write (base64 .b64decode (folder ))
125-
126- with ZipFile (self .zipfilename , 'r' ) as myzip :
127- # should find these. otherwise it will raise a `KeyError`
128- myzip .read ('1.txt' )
129- myzip .read ('2.txt' )
130-
13195 def test_background_app (self ):
13296 self .driver .background_app (1 )
13397 sleep (3 )
@@ -257,6 +221,6 @@ def test_device_time(self):
257221 parse (date_time )
258222
259223
260- if __name__ == " __main__" :
224+ if __name__ == ' __main__' :
261225 suite = unittest .TestLoader ().loadTestsFromTestCase (AppiumTests )
262226 unittest .TextTestRunner (verbosity = 2 ).run (suite )
0 commit comments