diff --git a/src/runtime/Properties/AssemblyInfo.cs b/src/runtime/Properties/AssemblyInfo.cs index 3417bccc8..b05fcc8bf 100644 --- a/src/runtime/Properties/AssemblyInfo.cs +++ b/src/runtime/Properties/AssemblyInfo.cs @@ -1,3 +1,5 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Python.EmbeddingTest, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")] + +[assembly: InternalsVisibleTo("Python.Test, PublicKey=00240000048000009400000006020000002400005253413100040000110000005ffd8f49fb44ab0641b3fd8d55e749f716e6dd901032295db641eb98ee46063cbe0d4a1d121ef0bc2af95f8a7438d7a80a3531316e6b75c2dae92fb05a99f03bf7e0c03980e1c3cfb74ba690aca2f3339ef329313bcc5dccced125a4ffdc4531dcef914602cd5878dc5fbb4d4c73ddfbc133f840231343e013762884d6143189")] \ No newline at end of file diff --git a/src/testing/CodecTest.cs b/src/testing/CodecTest.cs index 74f77531b..f3c243dab 100644 --- a/src/testing/CodecTest.cs +++ b/src/testing/CodecTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Python.Runtime; namespace Python.Test { @@ -44,4 +45,12 @@ public int GetLength2(IList o) return o.Count; } } + + public static class CodecResetter + { + public static void Reset() + { + PyObjectConversions.Reset(); + } + } } diff --git a/src/testing/Python.Test.csproj b/src/testing/Python.Test.csproj index 78f3a3169..1f40f4518 100644 --- a/src/testing/Python.Test.csproj +++ b/src/testing/Python.Test.csproj @@ -3,6 +3,8 @@ netstandard2.0;net6.0 true true + ..\pythonnet.snk + true diff --git a/src/tests/test_codec.py b/tests/test_codec.py similarity index 88% rename from src/tests/test_codec.py rename to tests/test_codec.py index 9fdbfbbf5..9744d3856 100644 --- a/src/tests/test_codec.py +++ b/tests/test_codec.py @@ -1,49 +1,49 @@ -# -*- coding: utf-8 -*- - -"""Test conversions using codecs from client python code""" -import clr -import System -import pytest -import Python.Runtime -from Python.Test import ListConversionTester, ListMember - -class int_iterable(): - def __init__(self): - self.counter = 0 - def __iter__(self): - return self - def __next__(self): - if self.counter == 3: - raise StopIteration - self.counter = self.counter + 1 - return self.counter +# -*- coding: utf-8 -*- + +"""Test conversions using codecs from client python code""" +import clr +import System +import pytest +import Python.Runtime +from Python.Test import ListConversionTester, ListMember, CodecResetter + +class int_iterable(): + def __init__(self): + self.counter = 0 + def __iter__(self): + return self + def __next__(self): + if self.counter == 3: + raise StopIteration + self.counter = self.counter + 1 + return self.counter class obj_iterable(): - def __init__(self): - self.counter = 0 - def __iter__(self): - return self - def __next__(self): - if self.counter == 3: - raise StopIteration + def __init__(self): + self.counter = 0 + def __iter__(self): + return self + def __next__(self): + if self.counter == 3: + raise StopIteration self.counter = self.counter + 1 return ListMember(self.counter, "Number " + str(self.counter)) - -def test_iterable(): - """Test that a python iterable can be passed into a function that takes an IEnumerable""" - - #Python.Runtime.Codecs.ListDecoder.Register() - #Python.Runtime.Codecs.SequenceDecoder.Register() - Python.Runtime.Codecs.IterableDecoder.Register() + +def test_iterable(): + """Test that a python iterable can be passed into a function that takes an IEnumerable""" + + #Python.Runtime.Codecs.ListDecoder.Register() + #Python.Runtime.Codecs.SequenceDecoder.Register() + Python.Runtime.Codecs.IterableDecoder.Register() ob = ListConversionTester() - iterable = int_iterable() + iterable = int_iterable() assert 3 == ob.GetLength(iterable) iterable2 = obj_iterable() assert 3 == ob.GetLength2(iterable2) - Python.Runtime.PyObjectConversions.Reset() + CodecResetter.Reset() def test_sequence(): Python.Runtime.Codecs.SequenceDecoder.Register() @@ -55,7 +55,7 @@ def test_sequence(): tup2 = (ListMember(1, "one"), ListMember(2, "two"), ListMember(3, "three")) assert 3 == ob.GetLength(tup2) - Python.Runtime.PyObjectConversions.Reset() + CodecResetter.Reset() def test_list(): Python.Runtime.Codecs.SequenceDecoder.Register() @@ -67,4 +67,4 @@ def test_list(): l2 = [ListMember(1, "one"), ListMember(2, "two"), ListMember(3, "three")] assert 3 == ob.GetLength(l2) - Python.Runtime.PyObjectConversions.Reset() + CodecResetter.Reset() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy