| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 80dc9f0 commit 090ff9f
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | 1 | using System.Runtime.CompilerServices; | |
| 2 | 2 | ||
| 3 | 3 | [assembly: InternalsVisibleTo("Python.EmbeddingTest, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")] | |
| 4 | + | ||
| 5 | + [assembly: InternalsVisibleTo("Python.Test, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | using System.Collections.Generic; | |
| 3 | 3 | using System.Linq; | |
| 4 | 4 | using System.Text; | |
| 5 | + using Python.Runtime; | ||
| 5 | 6 | ||
| 6 | 7 | namespace Python.Test | |
| 7 | 8 | { | |
@@ -44,4 +45,12 @@ public int GetLength2(IList<ListMember> o) | |||
| 44 | 45 | return o.Count; | |
| 45 | 46 | } | |
| 46 | 47 | } | |
| 48 | + | ||
| 49 | + public static class CodecResetter | ||
| 50 | + { | ||
| 51 | + public static void Reset() | ||
| 52 | + { | ||
| 53 | + PyObjectConversions.Reset(); | ||
| 54 | + } | ||
| 55 | + } | ||
| 47 | 56 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,8 @@ | |||
| 3 | 3 | <TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks> | |
| 4 | 4 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |
| 5 | 5 | <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | |
| 6 | + <AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile> | ||
| 7 | + <SignAssembly>true</SignAssembly> | ||
| 6 | 8 | </PropertyGroup> | |
| 7 | 9 | <ItemGroup> | |
| 8 | 10 | <ProjectReference Include="..\runtime\Python.Runtime.csproj" /> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,49 +1,49 @@ | |||
| 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() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments