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

New loading based on clr_loader#1373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
filmor merged 9 commits intopythonnet:masterfromfilmor:clr-loader
Feb 14, 2021
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Run tests on .NET Core
  • Loading branch information
@filmor
filmor committedFeb 14, 2021
commit0d7e43aedf07c7ac897c921cbdec00af15367b37
14 changes: 11 additions & 3 deletions.github/workflows/main.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,9 +55,17 @@ jobs:
if: ${{ matrix.os == 'windows' }}
run: |
python -m pythonnet.find_libpython --export | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Python Tests
run: pytest

- name: Python Tests (Mono)
if: ${{ matrix.os != 'windows' }}
run: pytest --runtime mono

- name: Python Tests (.NET Core)
run: pytest --runtime netcore

- name: Python Tests (.NET Framework)
if: ${{ matrix.os == 'windows' }}
run: pytest --runtime netfx

- name: Embedding tests
run: dotnet test --runtime any-${{ matrix.platform }} src/embed_tests/
Expand Down
6 changes: 6 additions & 0 deletionspyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
[build-system]
requires = ["setuptools>=42", "wheel", "pycparser"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
xfail_strict = true
testpaths = [
"tests",
]
4 changes: 0 additions & 4 deletionssetup.cfg
View file
Open in desktop

This file was deleted.

7 changes: 2 additions & 5 deletionssrc/testing/Python.Test.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\runtime\Python.Runtime.csproj" />
</ItemGroup>

<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(MSBuildThisFileDirectory)..\tests\fixtures" />
</Target>
</Project>
56 changes: 0 additions & 56 deletionssrc/tests/conftest.py
View file
Open in desktop

This file was deleted.

View file
Open in desktop
Empty file.
File renamed without changes.
File renamed without changes.
101 changes: 101 additions & 0 deletionstests/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*-
# TODO: move tests one out of src to project root.
# TODO: travis has numpy on their workers. Maybe add tests?

"""Helpers for testing."""

import ctypes
import os
import sys
import sysconfig
from subprocess import check_call
from tempfile import mkdtemp
import shutil

import pytest

from pythonnet import set_runtime

# Add path for `Python.Test`
cwd = os.path.dirname(__file__)
fixtures_path = os.path.join(cwd, "fixtures")
sys.path.append(fixtures_path)

def pytest_addoption(parser):
parser.addoption(
"--runtime",
action="store",
default="default",
help="Must be one of default, netcore, netfx and mono"
)

def pytest_configure(config):
global bin_path
runtime_opt = config.getoption("runtime")

test_proj_path = os.path.join(cwd, "..", "src", "testing")

if runtime_opt not in ["netcore", "netfx", "mono", "default"]:
raise RuntimeError(f"Invalid runtime: {runtime_opt}")

bin_path = mkdtemp()

# tmpdir_factory.mktemp(f"pythonnet-{runtime_opt}")

fw = "net5.0" if runtime_opt == "netcore" else "netstandard2.0"

check_call(["dotnet", "publish", "-f", fw, "-o", bin_path, test_proj_path])

sys.path.append(bin_path)

if runtime_opt == "default":
pass
elif runtime_opt == "netfx":
from clr_loader import get_netfx
runtime = get_netfx()
set_runtime(runtime)
elif runtime_opt == "mono":
from clr_loader import get_mono
runtime = get_mono()
set_runtime(runtime)
elif runtime_opt == "netcore":
from clr_loader import get_coreclr
rt_config_path = os.path.join(bin_path, "Python.Test.runtimeconfig.json")
runtime = get_coreclr(rt_config_path)
set_runtime(runtime)

import clr
clr.AddReference("Python.Test")
clr.AddReference("System")
clr.AddReference("System.Collections")
clr.AddReference("System.Data")
clr.AddReference("System.Xml")


def pytest_unconfigure(config):
global bin_path
shutil.rmtree(bin_path)

def pytest_report_header(config):
"""Generate extra report headers"""
# FIXME: https://github.com/pytest-dev/pytest/issues/2257
is_64bits = sys.maxsize > 2**32
arch = "x64" if is_64bits else "x86"
ucs = ctypes.sizeof(ctypes.c_wchar)
libdir = sysconfig.get_config_var("LIBDIR")
shared = bool(sysconfig.get_config_var("Py_ENABLE_SHARED"))

header = ("Arch: {arch}, UCS: {ucs}, LIBDIR: {libdir}, "
"Py_ENABLE_SHARED: {shared}".format(**locals()))
return header


@pytest.fixture()
def filepath():
"""Returns full filepath for file in `fixtures` directory."""

def make_filepath(filename):
# http://stackoverflow.com/questions/18011902/parameter-to-a-fixture
return os.path.join(fixtures_path, filename)

return make_filepath
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

[8]ページ先頭

©2009-2025 Movatter.jp