templates.test_modules2

 1import smartpy as sp
 2
 3
 4@sp.module
 5def M2():
 6    class C(sp.Contract):
 7        def __init__(self, x, y):
 8            sp.cast(x, int)
 9            self.data.a = 42
10            self.data.b = x + y
11            self.data.x = 0
12
13        @sp.entrypoint
14        def myEntryPoint(self, params):
15            assert params == "abc"
16            self.data.x = 44
17
18
19@sp.add_test()
20def test():
21    s = sp.test_scenario("Abbrevs", M2)
22    c = M2.C(x=43, y=0)
23    s += c
24    s.verify(c.data.a == 42)
25    s.verify(c.data.b == 43)
26    s.verify(c.data.x == 0)
27    c.myEntryPoint("abc")
28    s.verify(c.data.a == 42)
29    s.verify(c.data.b == 43)
30    s.verify(c.data.x == 44)