1import smartpy as sp
2
3
4@sp.module
5def M():
6 class C(sp.Contract):
7 def __init__(self):
8 pass
9
10 @sp.private
11 def test_median(self):
12 assert statistics.median([1, 3, 5, 7, 9, 11, 13]) == 7
13 assert statistics.median([3, 13, 2, 34, 11, 26, 47]) == 13
14 assert (
15 statistics.median(
16 [4, 17, 77, 25, 22, 23, 92, 82, 40, 24, 14, 12, 67, 23, 29]
17 )
18 == 24
19 )
20
21 @sp.entrypoint
22 def ep(self):
23 self.test_median()
24
25
26@sp.add_test()
27def test():
28 s = sp.test_scenario("Test", [sp.list_utils, sp.math, sp.statistics, M])
29 c = M.C()
30 s += c
31 c.ep()