run-tests

작성자: microsoft

로컬에서 pytest 테스트를 실행하기 위한 가이드입니다. 코드 변경 사항을 검증하기 위해 테스트를 실행할 때 사용하세요.

npx skills add https://github.com/microsoft/semantic-link-labs --skill run-tests

Running Tests

This skill covers running pytest tests for the Semantic Link Labs project.

When to Use This Skill

Use this skill when you need to:

  • Run unit tests to verify code changes
  • Run specific tests by name
  • Debug failing tests
  • Validate changes before committing

Test Framework

ComponentDetails
Frameworkpytest
Locationtests/ directory
Configurationpyproject.toml

Prerequisites

Install Development Dependencies

# Install package in editable mode with test dependencies
pip install -e ".[test]"

Environment Setup

Create conda environment from environment.yml:

conda env create -f environment.yml
conda activate fabric
pip install -e .

Running Tests

Basic Commands

# Run all tests
pytest -s tests/

# Run with verbose output
pytest -sv tests/

# Run specific test file
pytest -s tests/test_example.py

# Run specific test by name pattern
pytest -s tests/ -k test_my_function

# Run multiple tests by pattern
pytest -s tests/ -k "test_list or test_create"

# Stop on first failure
pytest -sx tests/

Test Discovery

pytest automatically discovers tests in:

  • Files named test_*.py or *_test.py
  • Functions named test_*
  • Classes named Test*

Test Output Options

Verbose Output

# Show test names and results
pytest -v tests/

# Show test names with print statements
pytest -sv tests/

Show Print Statements

The -s flag captures stdout:

# Show print output during tests
pytest -s tests/

Show Test Durations

# Show slowest 10 tests
pytest --durations=10 tests/

Filtering Tests

By Test Name

# Run tests matching pattern
pytest -k "workspace" tests/

# Run tests NOT matching pattern
pytest -k "not slow" tests/

# Combine patterns
pytest -k "workspace and not admin" tests/

By File

# Run specific test file
pytest tests/test_workspaces.py

# Run tests in directory
pytest tests/admin/

Debugging Failed Tests

Stop on First Failure

pytest -x tests/

Enter Debugger on Failure

pytest --pdb tests/

Show Local Variables on Failure

pytest -l tests/

Increase Verbosity

pytest -vvv tests/

Test Structure

Basic Test Example

import pytest
import pandas as pd


def test_my_function_returns_dataframe():
    """Test that my_function returns a DataFrame."""
    from sempy_labs import my_function

    result = my_function()

    assert isinstance(result, pd.DataFrame)


def test_my_function_with_parameter():
    """Test my_function with specific parameter."""
    from sempy_labs import my_function

    result = my_function(workspace="Test Workspace")

    assert not result.empty
    assert "Name" in result.columns

Test with Expected Exception

def test_my_function_raises_on_invalid_input():
    """Test that my_function raises ValueError on invalid input."""
    from sempy_labs import my_function

    with pytest.raises(ValueError, match="Invalid"):
        my_function(invalid_param="bad value")

CI/CD Integration

The project uses GitHub Actions for CI. See .github/workflows/build.yaml:

- name: Test with pytest
  shell: bash -el {0}
  run: |
    pytest -s tests/

Pre-Commit Test Checklist

Before committing code changes:

# Run all tests
pytest -s tests/

# Run tests for modified area
pytest -s tests/ -k relevant_test_pattern

# Check for any failures
# If failures, fix code and re-run

Common Test Issues

Import Errors

If tests fail with import errors:

# Ensure package is installed in editable mode
pip install -e .

Missing Dependencies

If tests fail with missing package:

# Install test dependencies
pip install -e ".[test]"

Environment Issues

If tests behave unexpectedly:

# Recreate conda environment
conda env remove -n fabric
conda env create -f environment.yml
conda activate fabric
pip install -e .

microsoft의 다른 스킬

oss-growth
microsoft
OSS 성장 해커 페르소나
agent-framework-azure-ai-py
microsoft
Microsoft Agent Framework Python SDK(agent-framework-azure-ai)를 사용하여 Azure AI Foundry 에이전트를 구축합니다. AzureAIAgentsProvider로 지속적 에이전트를 만들 때, 호스팅 도구(코드 인터프리터, 파일 검색, 웹 검색)를 사용할 때, MCP 서버를 통합할 때, 대화 스레드를 관리할 때, 또는 스트리밍 응답을 구현할 때 사용합니다. 함수 도구, 구조화된 출력, 다중 도구 에이전트를 다룹니다.
development
airunway-aks-setup
microsoft
Set up AI Runway on AKS — from bare cluster to running model. Covers cluster verification, controller install, GPU assessment, provider setup, and first deployment. WHEN: "setup AI Runway", "onboard AKS cluster", "install AI Runway", "airunway setup", "deploy model to AKS", "GPU inference on AKS", "KAITO setup on AKS", "run LLM on AKS", "vLLM on AKS", "set up model serving on AKS", "AI Runway controller".
devops
appinsights-instrumentation
microsoft
Azure Application Insights로 웹앱을 계측하기 위한 지침입니다. 원격 분석 패턴, SDK 설정, 구성 참조를 제공합니다. WHEN: 앱 계측 방법, App Insights SDK, 원격 분석 패턴, App Insights란 무엇인가, Application Insights 지침, 계측 예시, APM 모범 사례.
devops
applicationinsights-web-ts
microsoft
브라우저/웹 앱을 Application Insights JavaScript SDK(@microsoft/applicationinsights-web)로 계측합니다. Real User Monitoring(RUM) — 페이지 뷰, 클릭, AJAX/fetch 종속성, 예외, 사용자 지정 이벤트, 백엔드 OpenTelemetry 트레이스와 상관관계가 있는 브라우저 측 GenAI 에이전트 트레이스에 사용합니다. SDK Loader Script 및 npm 설정, 프레임워크 확장(React, React Native, Angular), Click Analytics, 텔레메트리 이니셜라이저, 브라우저에서 생성된 에이전트/도구/모델 스팬에 대한 OTel GenAI 의미론적 규칙을 다룹니다.
devops
azure-ai-anomalydetector-java
microsoft
Azure AI Anomaly Detector SDK for Java로 이상 탐지 애플리케이션을 구축하세요. 단변량/다변량 이상 탐지, 시계열 분석 또는 AI 기반 모니터링을 구현할 때 사용하세요.
development
azure-ai-language-conversations-py
microsoft
azure-ai-language-conversations Python SDK를 사용하여 대화형 언어 이해(CLU)를 구현합니다. ConversationAnalysisClient로 대화 의도와 엔터티를 분석하거나, NLP 기능을 구축하거나, 애플리케이션에 언어 이해를 통합할 때 사용합니다.
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 for Python. ML 작업 영역, 작업, 모델, 데이터 세트, 컴퓨팅 및 파이프라인에 사용합니다. 트리거: "azure-ai-ml", "MLClient", "workspace", "model registry", "training jobs", "datasets".
development