How to use test_continuation method in localstack

Best Python code snippet using localstack_python

finalization.py

Source:finalization.py Github

copy

Full Screen

1import time, gc23from allegra import loginfo, async_loop, finalization456# boiler plate78def watch (finalized):9 "inspect the continuation"10 loginfo.log ('%r - %d: %r' % (11 finalized, 12 len (finalized.async_finalized), 13 finalized.async_finalized14 ))1516class Labeled (finalization.Finalization):17 "labeled test finalization"18 def __init__ (self, label): self.label = label19 def __repr__ (self): return self.label20 21class Watch (Labeled):22 "log test continuation and inspect the continuation"23 def __call__ (self, finalized):24 loginfo.log ('%r continue %r - %d: %r' % (25 self, finalized, 26 len (finalized.async_finalized), 27 finalized.async_finalized28 ))2930class Continue (Watch):31 32 label = 'Continue'33 34 def __init__ (self, finalizations):35 self.__call__, self.continued = finalization.continuation (36 finalizations37 )3839class Join (Watch):40 41 label = 'Join'4243 def __init__ (self, finalizations):44 self.finalizations = finalizations45 46 def __call__ (self, finalized):47 if self.finalizations:48 for joined in self.finalizations:49 joined.finalization = self50 self.finalizations = None51 else:52 watch (finalized)5354# Test Syntax5556def test_watch ():57 Watch ('A').finalization = Watch ('B')58 async_loop.dispatch ()5960def test_continuation ():61 "test Continuation, Continue, Join and finalization"62 Continue ((63 Watch ('begin'),64 Watch ('one'),65 Join ((66 Watch ('two'), 67 Watch ('three')68 )),69 Watch ('joined'),70 finalization.Branch ((71 Watch ('end'), 72 Watch ('branched'),73 ))74 ))75 async_loop.dispatch ()767778def test_cycle ():79 "test a finalizations' cycle collection"80 one = Watch ('one')81 two = Watch ('two')82 three = Watch ('three')83 four = Watch ('four')84 finalization.continuation ([one, two, three, four])85 four.cycle = three86 del one, two, three, four87 async_loop.dispatch ()88 gc.collect ()89 loginfo.log ('garbage: %r' % gc.garbage)90 for cycled in gc.garbage:91 cycled.finalization = None92 async_loop.dispatch ()93949596def test_scale (N, M, Finalization=finalization.Finalization, count=False):97 "test scales on a system"98 if count:99 Finalization.count = 0100 def finalize (finalization, finalized):101 Finalization.count += 1102 else:103 finalize = lambda finalization, finalized: None104 Finalization.__call__ = finalize105 t = time.clock ()106 c = []107 for i in range (M):108 f = Finalization ()109 c.append (f)110 for j in range (N):111 f.finalization = Finalization ()112 f = f.finalization113 t = time.clock () - t114 loginfo.log ('%d instanciations: %f seconds' % (N*M, t))115 t = time.clock ()116 del c117 finalization.async_loop.dispatch ()118 t = time.clock () - t119 try:120 loginfo.log ('%d finalizations: %f seconds' % (121 Finalization.count, t122 ))123 except:124 loginfo.log ('finalization: %f seconds' % t)125 126if __name__ == '__main__':127 test_watch ()128 test_continuation ()129 test_cycle ()130 test_scale (10, 10, count=False)131 test_scale (100, 100, count=False) ...

Full Screen

Full Screen

test_util.py

Source:test_util.py Github

copy

Full Screen

...30 def parse(self, code):31 return parse(definitions, SingleLineFeeder(code))32 def compare(self, expr1, expr2):33 assert expr1.sameQ(expr2)34 def test_continuation(self):35 self.incomplete_error("Sin[")36 self.check("Sin[\n0]", "Sin[0]")37 self.check("Sin[\n\n0]", "Sin[0]")38 def test_trailing_backslash(self):39 self.incomplete_error("x \\")40 self.check("x \\\ny", "Times[x, y]")41class MultiLineParserTests(UtilTests):42 def parse(self, code):43 return parse(definitions, MultiLineFeeder(code))44 def compare(self, expr1, expr2):45 assert expr1.sameQ(expr2)46 def test_trailing_backslash(self):47 self.incomplete_error("x \\")48 self.check("x \\\ny", "Times[x, y]")49 def test_continuation(self):50 self.incomplete_error("Sin[")51 self.check("Sin[\n0]", "Sin[0]")52 self.check("Sin[0\n]", "Sin[0]")53 self.check("Sin[\n\n0]", "Sin[0]")54 def test_CompoundExpression(self):55 self.check("f[a;\nb]", "f[CompoundExpression[a, b]]")56 self.check("f[a;\nb;\nc;]", "f[CompoundExpression[a, b, c, Null]]")57 self.check("f[a;\nb;\nc;\n]", "f[CompoundExpression[a, b, c, Null]]")58 self.check("a;^b", "Power[CompoundExpression[a, Null], b]")59 feeder = MultiLineFeeder("a;\n^b")60 self.compare(61 parse(definitions, feeder), self.parse("CompoundExpression[a, Null]")62 )63 self.assertRaises(InvalidSyntaxError, lambda f: parse(definitions, f), feeder)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful