Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit090ff9f

Browse files
authored
Ensure that codec tests are run (#1763)
* Move test_codec.py to the right directory* Call PyObjectConversions.Reset from Python via a proxy to keep it internal* Sign Python.Test DLL and make Python.Runtime internals visible for it
1 parent80dc9f0 commit090ff9f

File tree

4 files changed

+50
-37
lines changed

4 files changed

+50
-37
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
usingSystem.Runtime.CompilerServices;
22

33
[assembly:InternalsVisibleTo("Python.EmbeddingTest, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")]
4+
5+
[assembly:InternalsVisibleTo("Python.Test, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")]

‎src/testing/CodecTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
usingSystem.Collections.Generic;
33
usingSystem.Linq;
44
usingSystem.Text;
5+
usingPython.Runtime;
56

67
namespacePython.Test
78
{
@@ -44,4 +45,12 @@ public int GetLength2(IList<ListMember> o)
4445
returno.Count;
4546
}
4647
}
48+
49+
publicstaticclassCodecResetter
50+
{
51+
publicstaticvoidReset()
52+
{
53+
PyObjectConversions.Reset();
54+
}
55+
}
4756
}

‎src/testing/Python.Test.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
6+
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
7+
<SignAssembly>true</SignAssembly>
68
</PropertyGroup>
79
<ItemGroup>
810
<ProjectReferenceInclude="..\runtime\Python.Runtime.csproj" />
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
# -*- coding: utf-8 -*-
2-
3-
"""Test conversions using codecs from client python code"""
4-
importclr
5-
importSystem
6-
importpytest
7-
importPython.Runtime
8-
fromPython.TestimportListConversionTester,ListMember
9-
10-
classint_iterable():
11-
def__init__(self):
12-
self.counter=0
13-
def__iter__(self):
14-
returnself
15-
def__next__(self):
16-
ifself.counter==3:
17-
raiseStopIteration
18-
self.counter=self.counter+1
19-
returnself.counter
1+
# -*- coding: utf-8 -*-
2+
3+
"""Test conversions using codecs from client python code"""
4+
importclr
5+
importSystem
6+
importpytest
7+
importPython.Runtime
8+
fromPython.TestimportListConversionTester,ListMember,CodecResetter
9+
10+
classint_iterable():
11+
def__init__(self):
12+
self.counter=0
13+
def__iter__(self):
14+
returnself
15+
def__next__(self):
16+
ifself.counter==3:
17+
raiseStopIteration
18+
self.counter=self.counter+1
19+
returnself.counter
2020

2121
classobj_iterable():
22-
def__init__(self):
23-
self.counter=0
24-
def__iter__(self):
25-
returnself
26-
def__next__(self):
27-
ifself.counter==3:
28-
raiseStopIteration
22+
def__init__(self):
23+
self.counter=0
24+
def__iter__(self):
25+
returnself
26+
def__next__(self):
27+
ifself.counter==3:
28+
raiseStopIteration
2929
self.counter=self.counter+1
3030
returnListMember(self.counter,"Number "+str(self.counter))
31-
32-
deftest_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+
deftest_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()
3838
ob=ListConversionTester()
3939

40-
iterable=int_iterable()
40+
iterable=int_iterable()
4141
assert3==ob.GetLength(iterable)
4242

4343
iterable2=obj_iterable()
4444
assert3==ob.GetLength2(iterable2)
4545

46-
Python.Runtime.PyObjectConversions.Reset()
46+
CodecResetter.Reset()
4747

4848
deftest_sequence():
4949
Python.Runtime.Codecs.SequenceDecoder.Register()
@@ -55,7 +55,7 @@ def test_sequence():
5555
tup2= (ListMember(1,"one"),ListMember(2,"two"),ListMember(3,"three"))
5656
assert3==ob.GetLength(tup2)
5757

58-
Python.Runtime.PyObjectConversions.Reset()
58+
CodecResetter.Reset()
5959

6060
deftest_list():
6161
Python.Runtime.Codecs.SequenceDecoder.Register()
@@ -67,4 +67,4 @@ def test_list():
6767
l2= [ListMember(1,"one"),ListMember(2,"two"),ListMember(3,"three")]
6868
assert3==ob.GetLength(l2)
6969

70-
Python.Runtime.PyObjectConversions.Reset()
70+
CodecResetter.Reset()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp