- Use importlib.metadata for dynamic version (single source in pyproject.toml) - Clean up duplicate `import re` statements across modules - Add missing type hints to all public methods - Fix PATH auto-discovery for ilspycmd (~/.dotnet/tools) - Add pytest test suite with 35 tests covering models, metadata reader, wrapper - Bump version to 0.2.0, add CHANGELOG.md
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
"""Shared pytest fixtures for mcilspy tests."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_assembly_path() -> str:
|
|
"""Return path to a .NET assembly for testing.
|
|
|
|
Uses a known .NET SDK assembly that should exist on systems with dotnet installed.
|
|
"""
|
|
# Try to find a .NET SDK assembly
|
|
dotnet_base = Path("/usr/share/dotnet/sdk")
|
|
if dotnet_base.exists():
|
|
# Find any SDK version
|
|
for sdk_dir in dotnet_base.iterdir():
|
|
test_dll = sdk_dir / "Sdks" / "Microsoft.NET.Sdk" / "tools" / "net10.0" / "Microsoft.NET.Build.Tasks.dll"
|
|
if test_dll.exists():
|
|
return str(test_dll)
|
|
# Try older paths
|
|
for net_version in ["net9.0", "net8.0", "net7.0", "net6.0"]:
|
|
test_dll = sdk_dir / "Sdks" / "Microsoft.NET.Sdk" / "tools" / net_version / "Microsoft.NET.Build.Tasks.dll"
|
|
if test_dll.exists():
|
|
return str(test_dll)
|
|
|
|
# Fallback: any .dll in dotnet directory
|
|
for root, dirs, files in os.walk("/usr/share/dotnet"):
|
|
for f in files:
|
|
if f.endswith(".dll"):
|
|
return os.path.join(root, f)
|
|
|
|
pytest.skip("No .NET assembly found for testing")
|
|
|
|
|
|
@pytest.fixture
|
|
def nonexistent_path() -> str:
|
|
"""Return a path that doesn't exist."""
|
|
return "/nonexistent/path/to/assembly.dll"
|