- Notifications
You must be signed in to change notification settings - Fork768
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
b92d929 Replace clr module by loading through clr_loader
filmorfdb7144 Add Changelog entry
filmorf01a78c Fix domain reload tests and activate them on macOS
filmor0d7e43a Run tests on .NET Core
filmor67032ea Vendor System.Drawing.Point for testing on .NET Core
filmor8bc458b Use approximate comparison for single max/min value comparison
filmord46fa1e Adjust the import tests to use only commonly available deps
filmorf0011a5 Fix PythonTestRunner to work with new pytest setup
filmorc1a01b7 Drop references to the obsolete call
filmorFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Run tests on .NET Core
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit0d7e43aedf07c7ac897c921cbdec00af15367b37
There are no files selected for viewing
14 changes: 11 additions & 3 deletions.github/workflows/main.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletionspyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff 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
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
7 changes: 2 additions & 5 deletionssrc/testing/Python.Test.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,11 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks> | ||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
| <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\runtime\Python.Runtime.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
56 changes: 0 additions & 56 deletionssrc/tests/conftest.py
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Empty file removedsrc/tests/fixtures/netstandard2.0/.gitkeep
Empty file.
File renamed without changes.
File renamed without changes.
101 changes: 101 additions & 0 deletionstests/conftest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff 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.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.