| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,7 @@ install: | |||
| 46 | 46 | ||
| 47 | 47 | script: | |
| 48 | 48 | - python -m pytest | |
| 49 | - - $RUN_TESTS src/embed_tests/bin/$EMBED_TESTS_PATH/Python.EmbeddingTest.dll | ||
| 49 | + - $RUN_TESTS src/embed_tests/bin/$EMBED_TESTS_PATH/Python.EmbeddingTest.dll --labels=All | ||
| 50 | 50 | # does not work on Linux, because NuGet package for 2.3 is Windows only | |
| 51 | 51 | # - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' && $PERF_TESTS_PATH != '' ]]; then mono $NUNIT_PATH src/perf_tests/bin/$PERF_TESTS_PATH/Python.PerformanceTests.dll; fi" | |
| 52 | 52 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ | |||
| 15 | 15 | - Alex Earl ([@slide](https://github.com/slide)) | |
| 16 | 16 | - Alex Helms ([@alexhelms](https://github.com/alexhelms)) | |
| 17 | 17 | - Alexandre Catarino([@AlexCatarino](https://github.com/AlexCatarino)) | |
| 18 | + - Andrey Sant'Anna ([@andreydani](https://github.com/andreydani)) | ||
| 18 | 19 | - Arvid JB ([@ArvidJB](https://github.com/ArvidJB)) | |
| 19 | 20 | - Benoît Hudson ([@benoithudson](https://github.com/benoithudson)) | |
| 20 | 21 | - Bradley Friedman ([@leith-bartrich](https://github.com/leith-bartrich)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. | |||
| 29 | 29 | together with Nuitka | |
| 30 | 30 | - Fixes bug where delegates get casts (dotnetcore) | |
| 31 | 31 | - Determine size of interpreter longs at runtime | |
| 32 | + - Handling exceptions ocurred in ModuleObject's getattribute | ||
| 32 | 33 | ||
| 33 | 34 | ## [2.4.0][] | |
| 34 | 35 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,7 @@ | |||
| 1 | 1 | # Build `conda.recipe` only if this is a Pull_Request. Saves time for CI. | |
| 2 | 2 | ||
| 3 | + $stopwatch = [Diagnostics.Stopwatch]::StartNew() | ||
| 4 | + | ||
| 3 | 5 | $env:CONDA_PY = "$env:PY_VER" | |
| 4 | 6 | # Use pre-installed miniconda. Note that location differs if 64bit | |
| 5 | 7 | $env:CONDA_BLD = "C:\miniconda36" | |
@@ -30,7 +32,9 @@ if ($env:APPVEYOR_PULL_REQUEST_NUMBER -or $env:APPVEYOR_REPO_TAG_NAME -or $env:F | |||
| 30 | 32 | ||
| 31 | 33 | $CONDA_PKG=(conda build conda.recipe --output) | |
| 32 | 34 | Copy-Item $CONDA_PKG .\dist\ | |
| 33 | - Write-Host "Completed conda build recipe" -ForegroundColor "Green" | ||
| 35 | + | ||
| 36 | + $timeSpent = $stopwatch.Elapsed | ||
| 37 | + Write-Host "Completed conda build recipe in " $timeSpent -ForegroundColor "Green" | ||
| 34 | 38 | ||
| 35 | 39 | # Restore PATH back to original | |
| 36 | 40 | $env:path = $old_path | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,8 @@ | |||
| 1 | 1 | # Script to simplify AppVeyor configuration and resolve path to tools | |
| 2 | 2 | ||
| 3 | + $stopwatch = [Diagnostics.Stopwatch]::StartNew() | ||
| 4 | + [array]$timings = @() | ||
| 5 | + | ||
| 3 | 6 | # Test Runner framework being used for embedded tests | |
| 4 | 7 | $CS_RUNNER = "nunit3-console" | |
| 5 | 8 | ||
@@ -25,6 +28,17 @@ $PY = Get-Command python | |||
| 25 | 28 | $CS_TESTS = ".\src\embed_tests\bin\Python.EmbeddingTest.dll" | |
| 26 | 29 | $RUNTIME_DIR = ".\src\runtime\bin\" | |
| 27 | 30 | ||
| 31 | + function ReportTime { | ||
| 32 | + param([string] $action) | ||
| 33 | + | ||
| 34 | + $timeSpent = $stopwatch.Elapsed | ||
| 35 | + $timings += [pscustomobject]@{action=$action; timeSpent=$timeSpent} | ||
| 36 | + Write-Host $action " in " $timeSpent -ForegroundColor "Green" | ||
| 37 | + $stopwatch.Restart() | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + ReportTime "Preparation done" | ||
| 41 | + | ||
| 28 | 42 | # Run python tests with C# coverage | |
| 29 | 43 | Write-Host ("Starting Python tests") -ForegroundColor "Green" | |
| 30 | 44 | .$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:py.coverage ` | |
@@ -33,18 +47,24 @@ Write-Host ("Starting Python tests") -ForegroundColor "Green" | |||
| 33 | 47 | $PYTHON_STATUS = $LastExitCode | |
| 34 | 48 | if ($PYTHON_STATUS -ne 0) { | |
| 35 | 49 | Write-Host "Python tests failed, continuing to embedded tests" -ForegroundColor "Red" | |
| 50 | + ReportTime "" | ||
| 51 | + } else { | ||
| 52 | + ReportTime "Python tests completed" | ||
| 36 | 53 | } | |
| 37 | 54 | ||
| 38 | 55 | # Run Embedded tests with C# coverage | |
| 39 | 56 | Write-Host ("Starting embedded tests") -ForegroundColor "Green" | |
| 40 | 57 | .$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:cs.coverage ` | |
| 41 | - -target:"$CS_RUNNER" -targetargs:"$CS_TESTS" ` | ||
| 58 | + -target:"$CS_RUNNER" -targetargs:"$CS_TESTS --labels=All" ` | ||
| 42 | 59 | -filter:"+[*]Python.Runtime*" ` | |
| 43 | 60 | -returntargetcode | |
| 44 | 61 | $CS_STATUS = $LastExitCode | |
| 45 | 62 | if ($CS_STATUS -ne 0) { | |
| 46 | 63 | Write-Host "Embedded tests failed" -ForegroundColor "Red" | |
| 64 | + ReportTime "" | ||
| 47 | 65 | } else { | |
| 66 | + ReportTime "Embedded tests completed" | ||
| 67 | + | ||
| 48 | 68 | # NuGet for pythonnet-2.3 only has 64-bit binary for Python 3.5 | |
| 49 | 69 | # the test is only built using modern stack | |
| 50 | 70 | if (($env:PLATFORM -eq "x64") -and ($XPLAT) -and ($env:PYTHON_VERSION -eq "3.5")) { | |
@@ -60,6 +80,9 @@ if ($CS_STATUS -ne 0) { | |||
| 60 | 80 | $CS_PERF_STATUS = $LastExitCode | |
| 61 | 81 | if ($CS_PERF_STATUS -ne 0) { | |
| 62 | 82 | Write-Host "Performance tests (C#) failed" -ForegroundColor "Red" | |
| 83 | + ReportTime "" | ||
| 84 | + } else { | ||
| 85 | + ReportTime "Performance tests (C#) completed" | ||
| 63 | 86 | } | |
| 64 | 87 | } else { | |
| 65 | 88 | Write-Host ("Skipping performance tests for ", $env:PYTHON_VERSION) -ForegroundColor "Yellow" | |
@@ -82,9 +105,14 @@ if ($XPLAT){ | |||
| 82 | 105 | $CS_STATUS = $LastExitCode | |
| 83 | 106 | if ($CS_STATUS -ne 0) { | |
| 84 | 107 | Write-Host "Embedded tests for netcoreapp2.0 failed" -ForegroundColor "Red" | |
| 108 | + ReportTime "" | ||
| 109 | + } else { | ||
| 110 | + ReportTime ".NET Core 2.0 tests completed" | ||
| 85 | 111 | } | |
| 86 | 112 | } | |
| 87 | 113 | ||
| 114 | + Write-Host "Timings:" ($timings | Format-Table | Out-String) -ForegroundColor "Green" | ||
| 115 | + | ||
| 88 | 116 | # Set exit code to fail if either Python or Embedded tests failed | |
| 89 | 117 | if ($PYTHON_STATUS -ne 0 -or $CS_STATUS -ne 0 -or $CS_PERF_STATUS -ne 0) { | |
| 90 | 118 | Write-Host "Tests failed" -ForegroundColor "Red" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,86 @@ | |||
| 1 | + namespace Python.EmbeddingTest { | ||
| 2 | + using System; | ||
| 3 | + using System.Collections.Generic; | ||
| 4 | + using System.Text; | ||
| 5 | + using NUnit.Framework; | ||
| 6 | + using Python.Runtime; | ||
| 7 | + using Python.Runtime.Codecs; | ||
| 8 | + | ||
| 9 | + public class Codecs { | ||
| 10 | + [SetUp] | ||
| 11 | + public void SetUp() { | ||
| 12 | + PythonEngine.Initialize(); | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + [TearDown] | ||
| 16 | + public void Dispose() { | ||
| 17 | + PythonEngine.Shutdown(); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + [Test] | ||
| 21 | + public void ConversionsGeneric() { | ||
| 22 | + ConversionsGeneric<ValueTuple<int, string, object>, ValueTuple>(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + static void ConversionsGeneric<T, TTuple>() { | ||
| 26 | + TupleCodec<TTuple>.Register(); | ||
| 27 | + var tuple = Activator.CreateInstance(typeof(T), 42, "42", new object()); | ||
| 28 | + T restored = default; | ||
| 29 | + using (Py.GIL()) | ||
| 30 | + using (var scope = Py.CreateScope()) { | ||
| 31 | + void Accept(T value) => restored = value; | ||
| 32 | + var accept = new Action<T>(Accept).ToPython(); | ||
| 33 | + scope.Set(nameof(tuple), tuple); | ||
| 34 | + scope.Set(nameof(accept), accept); | ||
| 35 | + scope.Exec($"{nameof(accept)}({nameof(tuple)})"); | ||
| 36 | + Assert.AreEqual(expected: tuple, actual: restored); | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + [Test] | ||
| 41 | + public void ConversionsObject() { | ||
| 42 | + ConversionsObject<ValueTuple<int, string, object>, ValueTuple>(); | ||
| 43 | + } | ||
| 44 | + static void ConversionsObject<T, TTuple>() { | ||
| 45 | + TupleCodec<TTuple>.Register(); | ||
| 46 | + var tuple = Activator.CreateInstance(typeof(T), 42, "42", new object()); | ||
| 47 | + T restored = default; | ||
| 48 | + using (Py.GIL()) | ||
| 49 | + using (var scope = Py.CreateScope()) { | ||
| 50 | + void Accept(object value) => restored = (T)value; | ||
| 51 | + var accept = new Action<object>(Accept).ToPython(); | ||
| 52 | + scope.Set(nameof(tuple), tuple); | ||
| 53 | + scope.Set(nameof(accept), accept); | ||
| 54 | + scope.Exec($"{nameof(accept)}({nameof(tuple)})"); | ||
| 55 | + Assert.AreEqual(expected: tuple, actual: restored); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + [Test] | ||
| 60 | + public void TupleRoundtripObject() { | ||
| 61 | + TupleRoundtripObject<ValueTuple<int, string, object>, ValueTuple>(); | ||
| 62 | + } | ||
| 63 | + static void TupleRoundtripObject<T, TTuple>() { | ||
| 64 | + var tuple = Activator.CreateInstance(typeof(T), 42, "42", new object()); | ||
| 65 | + using (Py.GIL()) { | ||
| 66 | + var pyTuple = TupleCodec<TTuple>.Instance.TryEncode(tuple); | ||
| 67 | + Assert.IsTrue(TupleCodec<TTuple>.Instance.TryDecode(pyTuple, out object restored)); | ||
| 68 | + Assert.AreEqual(expected: tuple, actual: restored); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + [Test] | ||
| 73 | + public void TupleRoundtripGeneric() { | ||
| 74 | + TupleRoundtripGeneric<ValueTuple<int, string, object>, ValueTuple>(); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + static void TupleRoundtripGeneric<T, TTuple>() { | ||
| 78 | + var tuple = Activator.CreateInstance(typeof(T), 42, "42", new object()); | ||
| 79 | + using (Py.GIL()) { | ||
| 80 | + var pyTuple = TupleCodec<TTuple>.Instance.TryEncode(tuple); | ||
| 81 | + Assert.IsTrue(TupleCodec<TTuple>.Instance.TryDecode(pyTuple, out T restored)); | ||
| 82 | + Assert.AreEqual(expected: tuple, actual: restored); | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ | |||
| 23 | 23 | <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | |
| 24 | 24 | <PythonBuildDir Condition="'$(TargetFramework)'=='net40' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir> | |
| 25 | 25 | <PublishDir Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)_publish</PublishDir> | |
| 26 | - <LangVersion>6</LangVersion> | ||
| 26 | + <LangVersion>7.3</LangVersion> | ||
| 27 | 27 | <ErrorReport>prompt</ErrorReport> | |
| 28 | 28 | <CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants> | |
| 29 | 29 | <BaseDefineConstants>XPLAT</BaseDefineConstants> | |
@@ -77,13 +77,17 @@ | |||
| 77 | 77 | ||
| 78 | 78 | ||
| 79 | 79 | <ItemGroup> | |
| 80 | - <PackageReference Include="NUnit" Version="3.7.1" /> | ||
| 81 | - <PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" /> | ||
| 82 | - <PackageReference Include="NUnit3TestAdapter" Version="3.8.0" /> | ||
| 83 | - <PackageReference Include="NUnitLite" Version="3.7.2" /> | ||
| 80 | + <PackageReference Include="System.ValueTuple" Version="4.5.0" /> | ||
| 81 | + <PackageReference Include="NUnit" Version="3.12.0" /> | ||
| 82 | + <PackageReference Include="NUnit.ConsoleRunner" Version="3.11.1" /> | ||
| 83 | + <PackageReference Include="NUnit3TestAdapter" Version="3.16.1"> | ||
| 84 | + <PrivateAssets>all</PrivateAssets> | ||
| 85 | + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| 86 | + </PackageReference> | ||
| 87 | + <PackageReference Include="NUnitLite" Version="3.12.0" /> | ||
| 84 | 88 | </ItemGroup> | |
| 85 | 89 | <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'"> | |
| 86 | - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> | ||
| 90 | + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" /> | ||
| 87 | 91 | </ItemGroup> | |
| 88 | 92 | <ItemGroup> | |
| 89 | 93 | <ProjectReference Include="..\runtime\Python.Runtime.15.csproj" /> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ | |||
| 14 | 14 | <NoWarn>1591</NoWarn> | |
| 15 | 15 | <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | |
| 16 | 16 | <PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir> | |
| 17 | - <LangVersion>6</LangVersion> | ||
| 17 | + <LangVersion>7.3</LangVersion> | ||
| 18 | 18 | <RestorePackages>true</RestorePackages> | |
| 19 | 19 | <ErrorReport>prompt</ErrorReport> | |
| 20 | 20 | </PropertyGroup> | |
@@ -70,8 +70,11 @@ | |||
| 70 | 70 | </PropertyGroup> | |
| 71 | 71 | <ItemGroup> | |
| 72 | 72 | <Reference Include="Microsoft.CSharp" /> | |
| 73 | - <Reference Include="nunit.framework, Version=3.7.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> | ||
| 74 | - <HintPath>..\..\packages\NUnit.3.7.1\lib\net40\nunit.framework.dll</HintPath> | ||
| 73 | + <Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> | ||
| 74 | + <HintPath>..\..\packages\NUnit.3.12.0\lib\net40\nunit.framework.dll</HintPath> | ||
| 75 | + </Reference> | ||
| 76 | + <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | ||
| 77 | + <HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll</HintPath> | ||
| 75 | 78 | </Reference> | |
| 76 | 79 | <Reference Include="System" /> | |
| 77 | 80 | </ItemGroup> | |
@@ -80,6 +83,7 @@ | |||
| 80 | 83 | <None Include="packages.config" /> | |
| 81 | 84 | </ItemGroup> | |
| 82 | 85 | <ItemGroup> | |
| 86 | + <Compile Include="Codecs.cs" /> | ||
| 83 | 87 | <Compile Include="dynamic.cs" /> | |
| 84 | 88 | <Compile Include="pyimport.cs" /> | |
| 85 | 89 | <Compile Include="pyinitialize.cs" /> | |
@@ -126,4 +130,10 @@ | |||
| 126 | 130 | <Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" /> | |
| 127 | 131 | <!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /--> | |
| 128 | 132 | </Target> | |
| 133 | + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
| 134 | + <PropertyGroup> | ||
| 135 | + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
| 136 | + </PropertyGroup> | ||
| 137 | + <Error Condition="!Exists('..\..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit.3.12.0\build\NUnit.props'))" /> | ||
| 138 | + </Target> | ||
| 129 | 139 | </Project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | using System; | |
| 2 | + using System.Collections.Generic; | ||
| 2 | 3 | using NUnit.Framework; | |
| 3 | 4 | using Python.Runtime; | |
| 4 | 5 | using Python.Runtime.Platform; | |
@@ -113,9 +114,15 @@ public static void PyCheck_Iter_PyObject_IsIterable_ThreadingLock_Test() | |||
| 113 | 114 | // Create an instance of threading.Lock, which is one of the very few types that does not have the | |
| 114 | 115 | // TypeFlags.HaveIter set in Python 2. This tests a different code path in PyObject_IsIterable and PyIter_Check. | |
| 115 | 116 | var threading = Runtime.Runtime.PyImport_ImportModule("threading"); | |
| 117 | + Exceptions.ErrorCheck(threading); | ||
| 116 | 118 | var threadingDict = Runtime.Runtime.PyModule_GetDict(threading); | |
| 119 | + Exceptions.ErrorCheck(threadingDict); | ||
| 117 | 120 | var lockType = Runtime.Runtime.PyDict_GetItemString(threadingDict, "Lock"); | |
| 121 | + if (lockType == IntPtr.Zero) | ||
| 122 | + throw new KeyNotFoundException("class 'Lock' was not found in 'threading'"); | ||
| 123 | + | ||
| 118 | 124 | var lockInstance = Runtime.Runtime.PyObject_CallObject(lockType, Runtime.Runtime.PyTuple_New(0)); | |
| 125 | + Exceptions.ErrorCheck(lockInstance); | ||
| 119 | 126 | ||
| 120 | 127 | Assert.IsFalse(Runtime.Runtime.PyObject_IsIterable(lockInstance)); | |
| 121 | 128 | Assert.IsFalse(Runtime.Runtime.PyIter_Check(lockInstance)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | - <?xml version="1.0" encoding="utf-8"?> | ||
| 1 | + <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | 2 | <packages> | |
| 3 | - <package id="NUnit" version="3.7.1" targetFramework="net40" /> | ||
| 4 | - <package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net40" /> | ||
| 3 | + <package id="NUnit" version="3.12.0" targetFramework="net40" /> | ||
| 4 | + <package id="NUnit.ConsoleRunner" version="3.11.1" targetFramework="net40" /> | ||
| 5 | + <package id="System.ValueTuple" version="4.5.0" targetFramework="net40" /> | ||
| 5 | 6 | </packages> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments