зеркало из https://github.com/microsoft/iqsharp.git
Fix metadata (#730)
* Add test for metadata key in jupyter protocol. * Update jupyter-core. * Print better error messages on fail. * Skip test on 3.10.
This commit is contained in:
Родитель
d90578bb70
Коммит
c81f92d3f0
|
@ -5,6 +5,22 @@ $ErrorActionPreference = 'Stop'
|
|||
& "$PSScriptRoot/set-env.ps1"
|
||||
$script:AllOk = $True
|
||||
|
||||
function Get-ErrorMessage {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$true)]
|
||||
$Value
|
||||
);
|
||||
|
||||
process {
|
||||
if ($Value -is [System.Management.Automation.ErrorRecord]) {
|
||||
$Value.Exception.Message | Write-Output
|
||||
} else {
|
||||
$Value.ToString() | Write-Output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Test-CondaPackage {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
|
@ -25,7 +41,7 @@ function Test-CondaPackage {
|
|||
|
||||
process {
|
||||
Write-Host "##[info]Testing conda package $Path..."
|
||||
conda-build (Resolve-Path $Path) --test 2>&1 | ForEach-Object { "$_" };
|
||||
conda-build (Resolve-Path $Path) --test 2>&1 | Get-ErrorMessage;
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "##vso[task.logissue type=error;]conda-build --test failed for $Path.";
|
||||
$script:AllOk = $false;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
import unittest
|
||||
import jupyter_kernel_test
|
||||
|
||||
import sys
|
||||
|
||||
class MyKernelTests(jupyter_kernel_test.KernelTests):
|
||||
# Required --------------------------------------
|
||||
|
||||
|
@ -13,5 +15,31 @@ class MyKernelTests(jupyter_kernel_test.KernelTests):
|
|||
# language_info.name in a kernel_info_reply should match this
|
||||
language_name = "qsharp"
|
||||
|
||||
def test_iqsharp_metadata_is_correct(self):
|
||||
"""
|
||||
Some clients, e.g. nteract, require that metadata on displayable data
|
||||
is convertable to dict[str, dict[str, Any]]; we test that this is the
|
||||
case here.
|
||||
"""
|
||||
|
||||
# NB: There is a race condition in jupyter_kernel_test itself on 3.10
|
||||
# that can cause this test to false positive. Since these tests are
|
||||
# not intended to test Python integration, but Jupyter adherence
|
||||
# itself, the Python version is insignificant to this test and can
|
||||
# be safely locked down to 3.9. See tests on the qsharp-core package
|
||||
# for unit and integration testing of Q# + Python interop.
|
||||
if sys.version_info.minor >= 10:
|
||||
print("This test is not yet supported on Python 3.10.")
|
||||
raise unittest.SkipTest
|
||||
|
||||
self.flush_channels()
|
||||
reply, output_msgs = self.execute_helper("%version", timeout=30)
|
||||
self.assertEqual(output_msgs[0]['header']['msg_type'], 'display_data')
|
||||
self.assert_(isinstance(output_msgs[0]['content']['metadata'], dict))
|
||||
for mime_type, contents in output_msgs[0]['content']['metadata'].items():
|
||||
self.assert_(isinstance(mime_type, str))
|
||||
self.assert_(isinstance(contents, dict))
|
||||
self.assertEqual(contents, {})
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Jupyter.Core" Version="2.1.226704" />
|
||||
<PackageReference Include="Microsoft.Jupyter.Core" Version="3.0.233310" />
|
||||
<PackageReference Include="System.Reactive" Version="4.3.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче