Skip to content

Commit

Permalink
Module types has no attribute StringType #288
Browse files Browse the repository at this point in the history
- Use isinstance
  • Loading branch information
dtmilano committed Dec 9, 2020
1 parent bb891fe commit 8e0d04c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/com/dtmilano/android/viewclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import re
import socket
import os
import types
import time
import signal
import copy
Expand Down Expand Up @@ -3874,7 +3873,7 @@ def __findViewsWithAttributeInTreeThatMatches(self, attr, regex, root, rlist=[])
print("ERROR: no root, did you forget to call dump()?", file=sys.stderr)
return matchingViews

if type(root) == types.StringType and root == "ROOT":
if isinstance(root, str) and root == "ROOT":
root = self.root

if DEBUG:
Expand Down
4 changes: 4 additions & 0 deletions tests/comm/dtmilano/android/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@ def shell(self, cmd):
if m:
return self.uiAutomatorDump[self.language]

m = re.match('^cp /dev/null /sdcard/window_dump.xml.', cmd)
if m:
return self.uiAutomatorDump[self.language]

def getProperty(self, property):
if property == 'ro.serialno':
return self.serialno
Expand Down
6 changes: 3 additions & 3 deletions tests/comm/dtmilano/android/viewclienttests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,12 @@ def testFindViewsContainingPoint_filterApi17(self):
self.assertNotEqual(None, list)
self.assertNotEqual(0, len(list))

def testFindViewsWithArreibuteThatMatches(self):
def testFindViewsWithAttributeThatMatches(self):
device = MockDevice(version=28)
vc = ViewClient(device, device.serialno, adb=TRUE)
list = vc.findViewsWithAttributeThatMatches("text", re.compile(r"\S+"))
self.assertNotEquals(None, list)
self.assertEquals(6, len(list))
self.assertNotEqual(None, list)
self.assertEqual(6, len(list))


if __name__ == "__main__":
Expand Down

0 comments on commit 8e0d04c

Please sign in to comment.