Best Python code snippet using autotest_python
coverage.py
Source: coverage.py
...85 self.suite_spots = suite_spots86 self.excluding_suite = 087 88 def doRecursive(self, node):89 self.recordNodeLine(node)90 for n in node.getChildNodes():91 self.dispatch(n)92 visitStmt = visitModule = doRecursive93 94 def doCode(self, node):95 if hasattr(node, 'decorators') and node.decorators:96 self.dispatch(node.decorators)97 self.doSuite(node, node.code)98 99 visitFunction = visitClass = doCode100 def getFirstLine(self, node):101 # Find the first line in the tree node.102 lineno = node.lineno103 for n in node.getChildNodes():104 f = self.getFirstLine(n)105 if lineno and f:106 lineno = min(lineno, f)107 else:108 lineno = lineno or f109 return lineno110 def getLastLine(self, node):111 # Find the first line in the tree node.112 lineno = node.lineno113 for n in node.getChildNodes():114 lineno = max(lineno, self.getLastLine(n))115 return lineno116 117 def doStatement(self, node):118 self.recordLine(self.getFirstLine(node))119 visitAssert = visitAssign = visitAssTuple = visitDiscard = visitPrint = \120 visitPrintnl = visitRaise = visitSubscript = \121 visitDecorators = \122 doStatement123 124 def recordNodeLine(self, node):125 return self.recordLine(node.lineno)126 127 def recordLine(self, lineno):128 # Returns a bool, whether the line is included or excluded.129 if lineno:130 # Multi-line tests introducing suites have to get charged to their131 # keyword.132 if lineno in self.suite_spots:133 lineno = self.suite_spots[lineno][0]134 # If we're inside an exluded suite, record that this line was135 # excluded.136 if self.excluding_suite:137 self.excluded[lineno] = 1138 return 0139 # If this line is excluded, or suite_spots maps this line to140 # another line that is exlcuded, then we're excluded.141 elif self.excluded.has_key(lineno) or \142 self.suite_spots.has_key(lineno) and \143 self.excluded.has_key(self.suite_spots[lineno][1]):144 return 0145 # Otherwise, this is an executable line.146 else:147 self.statements[lineno] = 1148 return 1149 return 0150 151 default = recordNodeLine152 153 def recordAndDispatch(self, node):154 self.recordNodeLine(node)155 self.dispatch(node)156 def doSuite(self, intro, body, exclude=0):157 exsuite = self.excluding_suite158 if exclude or (intro and not self.recordNodeLine(intro)):159 self.excluding_suite = 1160 self.recordAndDispatch(body)161 self.excluding_suite = exsuite162 163 def doPlainWordSuite(self, prevsuite, suite):164 # Finding the exclude lines for else's is tricky, because they aren't165 # present in the compiler parse tree. Look at the previous suite,166 # and find its last line. If any line between there and the else's167 # first line are excluded, then we exclude the else.168 lastprev = self.getLastLine(prevsuite)169 firstelse = self.getFirstLine(suite)170 for l in range(lastprev+1, firstelse):171 if self.suite_spots.has_key(l):172 self.doSuite(None, suite, exclude=self.excluded.has_key(l))...
CovParse.py
Source: CovParse.py
...48 self.excluded = excluded49 self.suite_spots = suite_spots50 self.excluding_suite = 051 def doRecursive(self, node):52 self.recordNodeLine(node)53 for n in node.getChildNodes():54 self.dispatch(n)55 visitStmt = visitModule = doRecursive56 def doCode(self, node):57 if hasattr(node, 'decorators') and node.decorators:58 self.dispatch(node.decorators)59 self.recordAndDispatch(node.code)60 else:61 self.doSuite(node, node.code)62 visitFunction = visitClass = doCode63 def getFirstLine(self, node):64 # Find the first line in the tree node.65 lineno = node.lineno66 for n in node.getChildNodes():67 f = self.getFirstLine(n)68 if lineno and f:69 lineno = min(lineno, f)70 else:71 lineno = lineno or f72 return lineno73 def getLastLine(self, node):74 # Find the first line in the tree node.75 lineno = node.lineno76 for n in node.getChildNodes():77 lineno = max(lineno, self.getLastLine(n))78 return lineno79 def doStatement(self, node):80 self.recordLine(self.getFirstLine(node))81 visitAssert = visitAssign = visitAssTuple = visitDiscard = visitPrint = \82 visitPrintnl = visitRaise = visitSubscript = visitDecorators = \83 doStatement84 def recordNodeLine(self, node):85 return self.recordLine(node.lineno)86 def recordLine(self, lineno):87 # Returns a bool, whether the line is included or excluded.88 # print("REC", lineno)89 if lineno:90 self.all_statements[lineno] = 191 # Multi-line tests introducing suites have to get charged to their92 # keyword.93 if lineno in self.suite_spots:94 lineno = self.suite_spots[lineno][0]95 # If we're inside an exluded suite, record that this line was96 # excluded.97 if self.excluding_suite:98 # print("EXCLUDE", lineno, self.excluding_suite)99 self.excluded[lineno] = self.excluding_suite100 return self.excluding_suite101 # If this line is excluded, or suite_spots maps this line to102 # another line that is excluded, then we're excluded.103 elif self.excluded.has_key(lineno):104 return self.excluded[lineno]105 elif self.suite_spots.has_key(lineno) and \106 self.excluded.has_key(self.suite_spots[lineno][1]):107 return self.excluded[self.suite_spots[lineno][1]]108 # Otherwise, this is an executable line.109 else:110 self.statements[lineno] = 1111 return 1112 return 0113 default = recordNodeLine114 def recordAndDispatch(self, node):115 self.recordNodeLine(node)116 self.dispatch(node)117 def doSuite(self, intro, body, exclude=0, qq=0):118 exsuite = self.excluding_suite119 exclTag = None120 # if not exclude and intro:121 if intro:122 # if qq:123 # print("SUITE", intro.lineno, body.__class__, len(body.nodes))124 exclTag = self.recordNodeLine(intro)125 if exclude:126 self.excluding_suite = exclude127 elif exclTag not in [None, 1, 0]:128 self.excluding_suite = exclTag129 # if qq or self.excluding_suite == 1:130 # print("EXCL-1", body.lineno, self.excluding_suite, exsuite, exclude, exclTag)131 self.recordAndDispatch(body)132 self.excluding_suite = exsuite133 # if qq:134 # print("EXCL-2", body.lineno, self.excluding_suite, exsuite)135 def doPlainWordSuite(self, prevsuite, suite):136 # Finding the exclude lines for else's is tricky, because they aren't137 # present in the compiler parse tree. Look at the previous suite,138 # and find its last line. If any line between there and the else's139 # first line are excluded, then we exclude the else.140 lastprev = self.getLastLine(prevsuite)141 firstelse = self.getFirstLine(suite)142 for l in range(lastprev+1, firstelse):143 if self.suite_spots.has_key(l):144 self.doSuite(None, suite, exclude=self.excluded.get(l, 0))145 break146 else:147 self.doSuite(None, suite)148 def doElse(self, prevsuite, node):149 if node.else_:150 self.doPlainWordSuite(prevsuite, node.else_)151 def visitFor(self, node):152 self.doSuite(node, node.body)153 self.doElse(node.body, node)154 def visitIf(self, node):155 # The first test has to be handled separately from the rest.156 # The first test is credited to the line with the "if", but the others157 # are credited to the line with the test for the elif.158 exsuite = self.excluding_suite159 exclTag = self.recordNodeLine(node)160 if exclTag not in [None, 1, 0]:161 self.excluding_suite = exclTag162 # print("IF", node.lineno, self.excluding_suite)163 # print("EXCL-XX", node.lineno, self.excluding_suite, exsuite)164 self.doSuite(node, node.tests[0][1])165 for t, n in node.tests[1:]:166 self.doSuite(t, n, qq=1)167 # print("EXCL-YY", node.lineno, self.excluding_suite, exsuite)168 self.doElse(node.tests[-1][1], node)169 # print("EXCL-ZZ", node.lineno, self.excluding_suite, exsuite)170 self.excluding_suite = exsuite171 def visitWhile(self, node):172 self.doSuite(node, node.body)173 self.doElse(node.body, node)...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!