ยปCore Development>Code coverage>Lib/test/list_tests.py

Python code coverage for Lib/test/list_tests.py

#countcontent
1n/a"""
2n/aTests common to list and UserList.UserList
3n/a"""
4n/a
5n/aimport sys
6n/aimport os
7n/afrom functools import cmp_to_key
8n/a
9n/afrom test import support, seq_tests
10n/a
11n/a
12n/aclass CommonTest(seq_tests.CommonTest):
13n/a
14n/a def test_init(self):
15n/a # Iterable arg is optional
16n/a self.assertEqual(self.type2test([]), self.type2test())
17n/a
18n/a # Init clears previous values
19n/a a = self.type2test([1, 2, 3])
20n/a a.__init__()
21n/a self.assertEqual(a, self.type2test([]))
22n/a
23n/a # Init overwrites previous values
24n/a a = self.type2test([1, 2, 3])
25n/a a.__init__([4, 5, 6])
26n/a self.assertEqual(a, self.type2test([4, 5, 6]))
27n/a
28n/a # Mutables always return a new object
29n/a b = self.type2test(a)
30n/a self.assertNotEqual(id(a), id(b))
31n/a self.assertEqual(a, b)
32n/a
33n/a def test_getitem_error(self):
34n/a msg = "list indices must be integers or slices"
35n/a with self.assertRaisesRegex(TypeError, msg):
36n/a a = []
37n/a a['a'] = "python"
38n/a
39n/a def test_repr(self):
40n/a l0 = []
41n/a l2 = [0, 1, 2]
42n/a a0 = self.type2test(l0)
43n/a a2 = self.type2test(l2)
44n/a
45n/a self.assertEqual(str(a0), str(l0))
46n/a self.assertEqual(repr(a0), repr(l0))
47n/a self.assertEqual(repr(a2), repr(l2))
48n/a self.assertEqual(str(a2), "[0, 1, 2]")
49n/a self.assertEqual(repr(a2), "[0, 1, 2]")
50n/a
51n/a a2.append(a2)
52n/a a2.append(3)
53n/a self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
54n/a self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
55n/a
56n/a l0 = []
57n/a for i in range(sys.getrecursionlimit() + 100):
58n/a l0 = [l0]
59n/a self.assertRaises(RecursionError, repr, l0)
60n/a
61n/a def test_print(self):
62n/a d = self.type2test(range(200))
63n/a d.append(d)
64n/a d.extend(range(200,400))
65n/a d.append(d)
66n/a d.append(400)
67n/a try:
68n/a with open(support.TESTFN, "w") as fo:
69n/a fo.write(str(d))
70n/a with open(support.TESTFN, "r") as fo:
71n/a self.assertEqual(fo.read(), repr(d))
72n/a finally:
73n/a os.remove(support.TESTFN)
74n/a
75n/a def test_set_subscript(self):
76n/a a = self.type2test(range(20))
77n/a self.assertRaises(ValueError, a.__setitem__, slice(0, 10, 0), [1,2,3])
78n/a self.assertRaises(TypeError, a.__setitem__, slice(0, 10), 1)
79n/a self.assertRaises(ValueError, a.__setitem__, slice(0, 10, 2), [1,2])
80n/a self.assertRaises(TypeError, a.__getitem__, 'x', 1)
81n/a a[slice(2,10,3)] = [1,2,3]
82n/a self.assertEqual(a, self.type2test([0, 1, 1, 3, 4, 2, 6, 7, 3,
83n/a 9, 10, 11, 12, 13, 14, 15,
84n/a 16, 17, 18, 19]))
85n/a
86n/a def test_reversed(self):
87n/a a = self.type2test(range(20))
88n/a r = reversed(a)
89n/a self.assertEqual(list(r), self.type2test(range(19, -1, -1)))
90n/a self.assertRaises(StopIteration, next, r)
91n/a self.assertEqual(list(reversed(self.type2test())),
92n/a self.type2test())
93n/a # Bug 3689: make sure list-reversed-iterator doesn't have __len__
94n/a self.assertRaises(TypeError, len, reversed([1,2,3]))
95n/a
96n/a def test_setitem(self):
97n/a a = self.type2test([0, 1])
98n/a a[0] = 0
99n/a a[1] = 100
100n/a self.assertEqual(a, self.type2test([0, 100]))
101n/a a[-1] = 200
102n/a self.assertEqual(a, self.type2test([0, 200]))
103n/a a[-2] = 100
104n/a self.assertEqual(a, self.type2test([100, 200]))
105n/a self.assertRaises(IndexError, a.__setitem__, -3, 200)
106n/a self.assertRaises(IndexError, a.__setitem__, 2, 200)
107n/a
108n/a a = self.type2test([])
109n/a self.assertRaises(IndexError, a.__setitem__, 0, 200)
110n/a self.assertRaises(IndexError, a.__setitem__, -1, 200)
111n/a self.assertRaises(TypeError, a.__setitem__)
112n/a
113n/a a = self.type2test([0,1,2,3,4])
114n/a a[0] = 1
115n/a a[1] = 2
116n/a a[2] = 3
117n/a self.assertEqual(a, self.type2test([1,2,3,3,4]))
118n/a a[0] = 5
119n/a a[1] = 6
120n/a a[2] = 7
121n/a self.assertEqual(a, self.type2test([5,6,7,3,4]))
122n/a a[-2] = 88
123n/a a[-1] = 99
124n/a self.assertEqual(a, self.type2test([5,6,7,88,99]))
125n/a a[-2] = 8
126n/a a[-1] = 9
127n/a self.assertEqual(a, self.type2test([5,6,7,8,9]))
128n/a
129n/a msg = "list indices must be integers or slices"
130n/a with self.assertRaisesRegex(TypeError, msg):
131n/a a['a'] = "python"
132n/a
133n/a def test_delitem(self):
134n/a a = self.type2test([0, 1])
135n/a del a[1]
136n/a self.assertEqual(a, [0])
137n/a del a[0]
138n/a self.assertEqual(a, [])
139n/a
140n/a a = self.type2test([0, 1])
141n/a del a[-2]
142n/a self.assertEqual(a, [1])
143n/a del a[-1]
144n/a self.assertEqual(a, [])
145n/a
146n/a a = self.type2test([0, 1])
147n/a self.assertRaises(IndexError, a.__delitem__, -3)
148n/a self.assertRaises(IndexError, a.__delitem__, 2)
149n/a
150n/a a = self.type2test([])
151n/a self.assertRaises(IndexError, a.__delitem__, 0)
152n/a
153n/a self.assertRaises(TypeError, a.__delitem__)
154n/a
155n/a def test_setslice(self):
156n/a l = [0, 1]
157n/a a = self.type2test(l)
158n/a
159n/a for i in range(-3, 4):
160n/a a[:i] = l[:i]
161n/a self.assertEqual(a, l)
162n/a a2 = a[:]
163n/a a2[:i] = a[:i]
164n/a self.assertEqual(a2, a)
165n/a a[i:] = l[i:]
166n/a self.assertEqual(a, l)
167n/a a2 = a[:]
168n/a a2[i:] = a[i:]
169n/a self.assertEqual(a2, a)
170n/a for j in range(-3, 4):
171n/a a[i:j] = l[i:j]
172n/a self.assertEqual(a, l)
173n/a a2 = a[:]
174n/a a2[i:j] = a[i:j]
175n/a self.assertEqual(a2, a)
176n/a
177n/a aa2 = a2[:]
178n/a aa2[:0] = [-2, -1]
179n/a self.assertEqual(aa2, [-2, -1, 0, 1])
180n/a aa2[0:] = []
181n/a self.assertEqual(aa2, [])
182n/a
183n/a a = self.type2test([1, 2, 3, 4, 5])
184n/a a[:-1] = a
185n/a self.assertEqual(a, self.type2test([1, 2, 3, 4, 5, 5]))
186n/a a = self.type2test([1, 2, 3, 4, 5])
187n/a a[1:] = a
188n/a self.assertEqual(a, self.type2test([1, 1, 2, 3, 4, 5]))
189n/a a = self.type2test([1, 2, 3, 4, 5])
190n/a a[1:-1] = a
191n/a self.assertEqual(a, self.type2test([1, 1, 2, 3, 4, 5, 5]))
192n/a
193n/a a = self.type2test([])
194n/a a[:] = tuple(range(10))
195n/a self.assertEqual(a, self.type2test(range(10)))
196n/a
197n/a self.assertRaises(TypeError, a.__setitem__, slice(0, 1, 5))
198n/a
199n/a self.assertRaises(TypeError, a.__setitem__)
200n/a
201n/a def test_delslice(self):
202n/a a = self.type2test([0, 1])
203n/a del a[1:2]
204n/a del a[0:1]
205n/a self.assertEqual(a, self.type2test([]))
206n/a
207n/a a = self.type2test([0, 1])
208n/a del a[1:2]
209n/a del a[0:1]
210n/a self.assertEqual(a, self.type2test([]))
211n/a
212n/a a = self.type2test([0, 1])
213n/a del a[-2:-1]
214n/a self.assertEqual(a, self.type2test([1]))
215n/a
216n/a a = self.type2test([0, 1])
217n/a del a[-2:-1]
218n/a self.assertEqual(a, self.type2test([1]))
219n/a
220n/a a = self.type2test([0, 1])
221n/a del a[1:]
222n/a del a[:1]
223n/a self.assertEqual(a, self.type2test([]))
224n/a
225n/a a = self.type2test([0, 1])
226n/a del a[1:]
227n/a del a[:1]
228n/a self.assertEqual(a, self.type2test([]))
229n/a
230n/a a = self.type2test([0, 1])
231n/a del a[-1:]
232n/a self.assertEqual(a, self.type2test([0]))
233n/a
234n/a a = self.type2test([0, 1])
235n/a del a[-1:]
236n/a self.assertEqual(a, self.type2test([0]))
237n/a
238n/a a = self.type2test([0, 1])
239n/a del a[:]
240n/a self.assertEqual(a, self.type2test([]))
241n/a
242n/a def test_append(self):
243n/a a = self.type2test([])
244n/a a.append(0)
245n/a a.append(1)
246n/a a.append(2)
247n/a self.assertEqual(a, self.type2test([0, 1, 2]))
248n/a
249n/a self.assertRaises(TypeError, a.append)
250n/a
251n/a def test_extend(self):
252n/a a1 = self.type2test([0])
253n/a a2 = self.type2test((0, 1))
254n/a a = a1[:]
255n/a a.extend(a2)
256n/a self.assertEqual(a, a1 + a2)
257n/a
258n/a a.extend(self.type2test([]))
259n/a self.assertEqual(a, a1 + a2)
260n/a
261n/a a.extend(a)
262n/a self.assertEqual(a, self.type2test([0, 0, 1, 0, 0, 1]))
263n/a
264n/a a = self.type2test("spam")
265n/a a.extend("eggs")
266n/a self.assertEqual(a, list("spameggs"))
267n/a
268n/a self.assertRaises(TypeError, a.extend, None)
269n/a self.assertRaises(TypeError, a.extend)
270n/a
271n/a # overflow test. issue1621
272n/a class CustomIter:
273n/a def __iter__(self):
274n/a return self
275n/a def __next__(self):
276n/a raise StopIteration
277n/a def __length_hint__(self):
278n/a return sys.maxsize
279n/a a = self.type2test([1,2,3,4])
280n/a a.extend(CustomIter())
281n/a self.assertEqual(a, [1,2,3,4])
282n/a
283n/a
284n/a def test_insert(self):
285n/a a = self.type2test([0, 1, 2])
286n/a a.insert(0, -2)
287n/a a.insert(1, -1)
288n/a a.insert(2, 0)
289n/a self.assertEqual(a, [-2, -1, 0, 0, 1, 2])
290n/a
291n/a b = a[:]
292n/a b.insert(-2, "foo")
293n/a b.insert(-200, "left")
294n/a b.insert(200, "right")
295n/a self.assertEqual(b, self.type2test(["left",-2,-1,0,0,"foo",1,2,"right"]))
296n/a
297n/a self.assertRaises(TypeError, a.insert)
298n/a
299n/a def test_pop(self):
300n/a a = self.type2test([-1, 0, 1])
301n/a a.pop()
302n/a self.assertEqual(a, [-1, 0])
303n/a a.pop(0)
304n/a self.assertEqual(a, [0])
305n/a self.assertRaises(IndexError, a.pop, 5)
306n/a a.pop(0)
307n/a self.assertEqual(a, [])
308n/a self.assertRaises(IndexError, a.pop)
309n/a self.assertRaises(TypeError, a.pop, 42, 42)
310n/a a = self.type2test([0, 10, 20, 30, 40])
311n/a
312n/a def test_remove(self):
313n/a a = self.type2test([0, 0, 1])
314n/a a.remove(1)
315n/a self.assertEqual(a, [0, 0])
316n/a a.remove(0)
317n/a self.assertEqual(a, [0])
318n/a a.remove(0)
319n/a self.assertEqual(a, [])
320n/a
321n/a self.assertRaises(ValueError, a.remove, 0)
322n/a
323n/a self.assertRaises(TypeError, a.remove)
324n/a
325n/a class BadExc(Exception):
326n/a pass
327n/a
328n/a class BadCmp:
329n/a def __eq__(self, other):
330n/a if other == 2:
331n/a raise BadExc()
332n/a return False
333n/a
334n/a a = self.type2test([0, 1, 2, 3])
335n/a self.assertRaises(BadExc, a.remove, BadCmp())
336n/a
337n/a class BadCmp2:
338n/a def __eq__(self, other):
339n/a raise BadExc()
340n/a
341n/a d = self.type2test('abcdefghcij')
342n/a d.remove('c')
343n/a self.assertEqual(d, self.type2test('abdefghcij'))
344n/a d.remove('c')
345n/a self.assertEqual(d, self.type2test('abdefghij'))
346n/a self.assertRaises(ValueError, d.remove, 'c')
347n/a self.assertEqual(d, self.type2test('abdefghij'))
348n/a
349n/a # Handle comparison errors
350n/a d = self.type2test(['a', 'b', BadCmp2(), 'c'])
351n/a e = self.type2test(d)
352n/a self.assertRaises(BadExc, d.remove, 'c')
353n/a for x, y in zip(d, e):
354n/a # verify that original order and values are retained.
355n/a self.assertIs(x, y)
356n/a
357n/a def test_count(self):
358n/a a = self.type2test([0, 1, 2])*3
359n/a self.assertEqual(a.count(0), 3)
360n/a self.assertEqual(a.count(1), 3)
361n/a self.assertEqual(a.count(3), 0)
362n/a
363n/a self.assertRaises(TypeError, a.count)
364n/a
365n/a class BadExc(Exception):
366n/a pass
367n/a
368n/a class BadCmp:
369n/a def __eq__(self, other):
370n/a if other == 2:
371n/a raise BadExc()
372n/a return False
373n/a
374n/a self.assertRaises(BadExc, a.count, BadCmp())
375n/a
376n/a def test_index(self):
377n/a u = self.type2test([0, 1])
378n/a self.assertEqual(u.index(0), 0)
379n/a self.assertEqual(u.index(1), 1)
380n/a self.assertRaises(ValueError, u.index, 2)
381n/a
382n/a u = self.type2test([-2, -1, 0, 0, 1, 2])
383n/a self.assertEqual(u.count(0), 2)
384n/a self.assertEqual(u.index(0), 2)
385n/a self.assertEqual(u.index(0, 2), 2)
386n/a self.assertEqual(u.index(-2, -10), 0)
387n/a self.assertEqual(u.index(0, 3), 3)
388n/a self.assertEqual(u.index(0, 3, 4), 3)
389n/a self.assertRaises(ValueError, u.index, 2, 0, -10)
390n/a
391n/a self.assertRaises(TypeError, u.index)
392n/a
393n/a class BadExc(Exception):
394n/a pass
395n/a
396n/a class BadCmp:
397n/a def __eq__(self, other):
398n/a if other == 2:
399n/a raise BadExc()
400n/a return False
401n/a
402n/a a = self.type2test([0, 1, 2, 3])
403n/a self.assertRaises(BadExc, a.index, BadCmp())
404n/a
405n/a a = self.type2test([-2, -1, 0, 0, 1, 2])
406n/a self.assertEqual(a.index(0), 2)
407n/a self.assertEqual(a.index(0, 2), 2)
408n/a self.assertEqual(a.index(0, -4), 2)
409n/a self.assertEqual(a.index(-2, -10), 0)
410n/a self.assertEqual(a.index(0, 3), 3)
411n/a self.assertEqual(a.index(0, -3), 3)
412n/a self.assertEqual(a.index(0, 3, 4), 3)
413n/a self.assertEqual(a.index(0, -3, -2), 3)
414n/a self.assertEqual(a.index(0, -4*sys.maxsize, 4*sys.maxsize), 2)
415n/a self.assertRaises(ValueError, a.index, 0, 4*sys.maxsize,-4*sys.maxsize)
416n/a self.assertRaises(ValueError, a.index, 2, 0, -10)
417n/a a.remove(0)
418n/a self.assertRaises(ValueError, a.index, 2, 0, 4)
419n/a self.assertEqual(a, self.type2test([-2, -1, 0, 1, 2]))
420n/a
421n/a # Test modifying the list during index's iteration
422n/a class EvilCmp:
423n/a def __init__(self, victim):
424n/a self.victim = victim
425n/a def __eq__(self, other):
426n/a del self.victim[:]
427n/a return False
428n/a a = self.type2test()
429n/a a[:] = [EvilCmp(a) for _ in range(100)]
430n/a # This used to seg fault before patch #1005778
431n/a self.assertRaises(ValueError, a.index, None)
432n/a
433n/a def test_reverse(self):
434n/a u = self.type2test([-2, -1, 0, 1, 2])
435n/a u2 = u[:]
436n/a u.reverse()
437n/a self.assertEqual(u, [2, 1, 0, -1, -2])
438n/a u.reverse()
439n/a self.assertEqual(u, u2)
440n/a
441n/a self.assertRaises(TypeError, u.reverse, 42)
442n/a
443n/a def test_clear(self):
444n/a u = self.type2test([2, 3, 4])
445n/a u.clear()
446n/a self.assertEqual(u, [])
447n/a
448n/a u = self.type2test([])
449n/a u.clear()
450n/a self.assertEqual(u, [])
451n/a
452n/a u = self.type2test([])
453n/a u.append(1)
454n/a u.clear()
455n/a u.append(2)
456n/a self.assertEqual(u, [2])
457n/a
458n/a self.assertRaises(TypeError, u.clear, None)
459n/a
460n/a def test_copy(self):
461n/a u = self.type2test([1, 2, 3])
462n/a v = u.copy()
463n/a self.assertEqual(v, [1, 2, 3])
464n/a
465n/a u = self.type2test([])
466n/a v = u.copy()
467n/a self.assertEqual(v, [])
468n/a
469n/a # test that it's indeed a copy and not a reference
470n/a u = self.type2test(['a', 'b'])
471n/a v = u.copy()
472n/a v.append('i')
473n/a self.assertEqual(u, ['a', 'b'])
474n/a self.assertEqual(v, u + ['i'])
475n/a
476n/a # test that it's a shallow, not a deep copy
477n/a u = self.type2test([1, 2, [3, 4], 5])
478n/a v = u.copy()
479n/a self.assertEqual(u, v)
480n/a self.assertIs(v[3], u[3])
481n/a
482n/a self.assertRaises(TypeError, u.copy, None)
483n/a
484n/a def test_sort(self):
485n/a u = self.type2test([1, 0])
486n/a u.sort()
487n/a self.assertEqual(u, [0, 1])
488n/a
489n/a u = self.type2test([2,1,0,-1,-2])
490n/a u.sort()
491n/a self.assertEqual(u, self.type2test([-2,-1,0,1,2]))
492n/a
493n/a self.assertRaises(TypeError, u.sort, 42, 42)
494n/a
495n/a def revcmp(a, b):
496n/a if a == b:
497n/a return 0
498n/a elif a < b:
499n/a return 1
500n/a else: # a > b
501n/a return -1
502n/a u.sort(key=cmp_to_key(revcmp))
503n/a self.assertEqual(u, self.type2test([2,1,0,-1,-2]))
504n/a
505n/a # The following dumps core in unpatched Python 1.5:
506n/a def myComparison(x,y):
507n/a xmod, ymod = x%3, y%7
508n/a if xmod == ymod:
509n/a return 0
510n/a elif xmod < ymod:
511n/a return -1
512n/a else: # xmod > ymod
513n/a return 1
514n/a z = self.type2test(range(12))
515n/a z.sort(key=cmp_to_key(myComparison))
516n/a
517n/a self.assertRaises(TypeError, z.sort, 2)
518n/a
519n/a def selfmodifyingComparison(x,y):
520n/a z.append(1)
521n/a if x == y:
522n/a return 0
523n/a elif x < y:
524n/a return -1
525n/a else: # x > y
526n/a return 1
527n/a self.assertRaises(ValueError, z.sort,
528n/a key=cmp_to_key(selfmodifyingComparison))
529n/a
530n/a self.assertRaises(TypeError, z.sort, 42, 42, 42, 42)
531n/a
532n/a def test_slice(self):
533n/a u = self.type2test("spam")
534n/a u[:2] = "h"
535n/a self.assertEqual(u, list("ham"))
536n/a
537n/a def test_iadd(self):
538n/a super().test_iadd()
539n/a u = self.type2test([0, 1])
540n/a u2 = u
541n/a u += [2, 3]
542n/a self.assertIs(u, u2)
543n/a
544n/a u = self.type2test("spam")
545n/a u += "eggs"
546n/a self.assertEqual(u, self.type2test("spameggs"))
547n/a
548n/a self.assertRaises(TypeError, u.__iadd__, None)
549n/a
550n/a def test_imul(self):
551n/a u = self.type2test([0, 1])
552n/a u *= 3
553n/a self.assertEqual(u, self.type2test([0, 1, 0, 1, 0, 1]))
554n/a u *= 0
555n/a self.assertEqual(u, self.type2test([]))
556n/a s = self.type2test([])
557n/a oldid = id(s)
558n/a s *= 10
559n/a self.assertEqual(id(s), oldid)
560n/a
561n/a def test_extendedslicing(self):
562n/a # subscript
563n/a a = self.type2test([0,1,2,3,4])
564n/a
565n/a # deletion
566n/a del a[::2]
567n/a self.assertEqual(a, self.type2test([1,3]))
568n/a a = self.type2test(range(5))
569n/a del a[1::2]
570n/a self.assertEqual(a, self.type2test([0,2,4]))
571n/a a = self.type2test(range(5))
572n/a del a[1::-2]
573n/a self.assertEqual(a, self.type2test([0,2,3,4]))
574n/a a = self.type2test(range(10))
575n/a del a[::1000]
576n/a self.assertEqual(a, self.type2test([1, 2, 3, 4, 5, 6, 7, 8, 9]))
577n/a # assignment
578n/a a = self.type2test(range(10))
579n/a a[::2] = [-1]*5
580n/a self.assertEqual(a, self.type2test([-1, 1, -1, 3, -1, 5, -1, 7, -1, 9]))
581n/a a = self.type2test(range(10))
582n/a a[::-4] = [10]*3
583n/a self.assertEqual(a, self.type2test([0, 10, 2, 3, 4, 10, 6, 7, 8 ,10]))
584n/a a = self.type2test(range(4))
585n/a a[::-1] = a
586n/a self.assertEqual(a, self.type2test([3, 2, 1, 0]))
587n/a a = self.type2test(range(10))
588n/a b = a[:]
589n/a c = a[:]
590n/a a[2:3] = self.type2test(["two", "elements"])
591n/a b[slice(2,3)] = self.type2test(["two", "elements"])
592n/a c[2:3:] = self.type2test(["two", "elements"])
593n/a self.assertEqual(a, b)
594n/a self.assertEqual(a, c)
595n/a a = self.type2test(range(10))
596n/a a[::2] = tuple(range(5))
597n/a self.assertEqual(a, self.type2test([0, 1, 1, 3, 2, 5, 3, 7, 4, 9]))
598n/a # test issue7788
599n/a a = self.type2test(range(10))
600n/a del a[9::1<<333]
601n/a
602n/a def test_constructor_exception_handling(self):
603n/a # Bug #1242657
604n/a class F(object):
605n/a def __iter__(self):
606n/a raise KeyboardInterrupt
607n/a self.assertRaises(KeyboardInterrupt, list, F())
608n/a
609n/a def test_exhausted_iterator(self):
610n/a a = self.type2test([1, 2, 3])
611n/a exhit = iter(a)
612n/a empit = iter(a)
613n/a for x in exhit: # exhaust the iterator
614n/a next(empit) # not exhausted
615n/a a.append(9)
616n/a self.assertEqual(list(exhit), [])
617n/a self.assertEqual(list(empit), [9])
618n/a self.assertEqual(a, self.type2test([1, 2, 3, 9]))