1
- # -*- coding: utf-8 -*-
2
-
3
- """Test conversions using codecs from client python code"""
4
- import clr
5
- import System
6
- import pytest
7
- import Python .Runtime
8
- from Python .Test import ListConversionTester , ListMember
9
-
10
- class int_iterable ():
11
- def __init__ (self ):
12
- self .counter = 0
13
- def __iter__ (self ):
14
- return self
15
- def __next__ (self ):
16
- if self .counter == 3 :
17
- raise StopIteration
18
- self .counter = self .counter + 1
19
- return self .counter
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """Test conversions using codecs from client python code"""
4
+ import clr
5
+ import System
6
+ import pytest
7
+ import Python .Runtime
8
+ from Python .Test import ListConversionTester , ListMember , CodecResetter
9
+
10
+ class int_iterable ():
11
+ def __init__ (self ):
12
+ self .counter = 0
13
+ def __iter__ (self ):
14
+ return self
15
+ def __next__ (self ):
16
+ if self .counter == 3 :
17
+ raise StopIteration
18
+ self .counter = self .counter + 1
19
+ return self .counter
20
20
21
21
class obj_iterable ():
22
- def __init__ (self ):
23
- self .counter = 0
24
- def __iter__ (self ):
25
- return self
26
- def __next__ (self ):
27
- if self .counter == 3 :
28
- raise StopIteration
22
+ def __init__ (self ):
23
+ self .counter = 0
24
+ def __iter__ (self ):
25
+ return self
26
+ def __next__ (self ):
27
+ if self .counter == 3 :
28
+ raise StopIteration
29
29
self .counter = self .counter + 1
30
30
return ListMember (self .counter , "Number " + str (self .counter ))
31
-
32
- def test_iterable ():
33
- """Test that a python iterable can be passed into a function that takes an IEnumerable<object>"""
34
-
35
- #Python.Runtime.Codecs.ListDecoder.Register()
36
- #Python.Runtime.Codecs.SequenceDecoder.Register()
37
- Python .Runtime .Codecs .IterableDecoder .Register ()
31
+
32
+ def test_iterable ():
33
+ """Test that a python iterable can be passed into a function that takes an IEnumerable<object>"""
34
+
35
+ #Python.Runtime.Codecs.ListDecoder.Register()
36
+ #Python.Runtime.Codecs.SequenceDecoder.Register()
37
+ Python .Runtime .Codecs .IterableDecoder .Register ()
38
38
ob = ListConversionTester ()
39
39
40
- iterable = int_iterable ()
40
+ iterable = int_iterable ()
41
41
assert 3 == ob .GetLength (iterable )
42
42
43
43
iterable2 = obj_iterable ()
44
44
assert 3 == ob .GetLength2 (iterable2 )
45
45
46
- Python . Runtime . PyObjectConversions .Reset ()
46
+ CodecResetter .Reset ()
47
47
48
48
def test_sequence ():
49
49
Python .Runtime .Codecs .SequenceDecoder .Register ()
@@ -55,7 +55,7 @@ def test_sequence():
55
55
tup2 = (ListMember (1 , "one" ), ListMember (2 , "two" ), ListMember (3 , "three" ))
56
56
assert 3 == ob .GetLength (tup2 )
57
57
58
- Python . Runtime . PyObjectConversions .Reset ()
58
+ CodecResetter .Reset ()
59
59
60
60
def test_list ():
61
61
Python .Runtime .Codecs .SequenceDecoder .Register ()
@@ -67,4 +67,4 @@ def test_list():
67
67
l2 = [ListMember (1 , "one" ), ListMember (2 , "two" ), ListMember (3 , "three" )]
68
68
assert 3 == ob .GetLength (l2 )
69
69
70
- Python . Runtime . PyObjectConversions .Reset ()
70
+ CodecResetter .Reset ()
0 commit comments