GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pythonnet/tests/conftest.py at v3.0.4 · pythonnet/pythonnet Expand file tree/ Copy pathconftest.pyMore file actions 120 lines (92 loc) · 3 KB / Copy pathconftest.pyFile metadata and controls120 lines (92 loc) · 3 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 # -*- 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 pathlib import Path from subprocess import check_call from tempfile import mkdtemp import shutil import pytest # Add path for `Python.Test` cwd = Path(__file__).parent fixtures_path = cwd / "fixtures" sys.path.append(str(fixtures_path)) def pytest_addoption(parser): parser.addoption( "--runtime", action="store", default="default", help="Must be one of default, coreclr, netfx and mono", ) collect_ignore = [] def pytest_configure(config): global bin_path if "clr" in sys.modules: # Already loaded (e.g. by the C# test runner), skip build import clr clr.AddReference("Python.Test") return runtime_opt = config.getoption("runtime") if runtime_opt not in ["coreclr", "netfx", "mono", "default"]: raise RuntimeError(f"Invalid runtime: {runtime_opt}") test_proj_path = cwd.parent / "src" / "testing" bin_path = Path(mkdtemp()) fw = "netstandard2.0" runtime_params = {} if runtime_opt == "coreclr": # This is optional now: # # fw = "net6.0" # runtime_params["runtime_config"] = str( # bin_path / "Python.Test.runtimeconfig.json" # ) collect_ignore.append("domain_tests/test_domain_reload.py") else: domain_tests_dir = cwd / "domain_tests" domain_bin_path = domain_tests_dir / "bin" build_cmd = [ "dotnet", "build", str(domain_tests_dir), "-o", str(domain_bin_path), ] is_64bits = sys.maxsize > 2**32 if not is_64bits: build_cmd += ["/p:Prefer32Bit=True"] check_call(build_cmd) check_call( ["dotnet", "publish", "-f", fw, "-o", str(bin_path), str(test_proj_path)] ) import os os.environ["PYTHONNET_RUNTIME"] = runtime_opt for k, v in runtime_params.items(): os.environ[f"PYTHONNET_{runtime_opt.upper()}_{k.upper()}"] = v import clr sys.path.append(str(bin_path)) clr.AddReference("Python.Test") def pytest_unconfigure(config): global bin_path try: shutil.rmtree(bin_path) except Exception: pass 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") return f"Arch: {arch}, UCS: {ucs}, LIBDIR: {libdir}" @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 |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |