[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BF599PPCMGVW0HRG0CQXZW":3,"skill-same:01M7BF599PPCMGVW0HRG0CQXZW":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7BF599PPCMGVW0HRG0CQXZW","python-testing",null,"pytest, TDD metodolojisi, fixture'lar, mocking, parametrizasyon ve coverage gereksinimleri kullanarak Python test stratejileri.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-Everything-claude-code\u002Fdocs\u002Ftr\u002Fskills\u002Fpython-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: python-testing\ndescription: pytest, TDD metodolojisi, fixture'lar, mocking, parametrizasyon ve coverage gereksinimleri kullanarak Python test stratejileri.\norigin: ECC\n---\n\n# Python Test Desenleri\n\npytest, TDD metodolojisi ve en iyi uygulamalar kullanarak Python uygulamaları için kapsamlı test stratejileri.\n\n## Ne Zaman Etkinleştirmeli\n\n- Yeni Python kodu yazarken (TDD'yi takip et: red, green, refactor)\n- Python projeleri için test suite'leri tasarlarken\n- Python test coverage'ını gözden geçirirken\n- Test altyapısını kurarken\n\n## Temel Test Felsefesi\n\n### Test-Driven Development (TDD)\n\nHer zaman TDD döngüsünü takip edin:\n\n1. **RED**: İstenen davranış için başarısız bir test yaz\n2. **GREEN**: Testi geçirmek için minimal kod yaz\n3. **REFACTOR**: Testleri yeşil tutarken kodu iyileştir\n\n```python\n# Adım 1: Başarısız test yaz (RED)\ndef test_add_numbers():\n    result = add(2, 3)\n    assert result == 5\n\n# Adım 2: Minimal implementasyon yaz (GREEN)\ndef add(a, b):\n    return a + b\n\n# Adım 3: Gerekirse refactor et (REFACTOR)\n```\n\n### Coverage Gereksinimleri\n\n- **Hedef**: 80%+ kod coverage'ı\n- **Kritik yollar**: 100% coverage gereklidir\n- Coverage'ı ölçmek için `pytest --cov` kullanın\n\n```bash\npytest --cov=mypackage --cov-report=term-missing --cov-report=html\n```\n\n## pytest Temelleri\n\n### Temel Test Yapısı\n\n```python\nimport pytest\n\ndef test_addition():\n    \"\"\"Temel toplama testi.\"\"\"\n    assert 2 + 2 == 4\n\ndef test_string_uppercase():\n    \"\"\"String büyük harf yapma testi.\"\"\"\n    text = \"hello\"\n    assert text.upper() == \"HELLO\"\n\ndef test_list_append():\n    \"\"\"Liste append testi.\"\"\"\n    items = [1, 2, 3]\n    items.append(4)\n    assert 4 in items\n    assert len(items) == 4\n```\n\n### Assertion'lar\n\n```python\n# Eşitlik\nassert result == expected\n\n# Eşitsizlik\nassert result != unexpected\n\n# Doğruluk değeri\nassert result  # Truthy\nassert not result  # Falsy\nassert result is True  # Tam olarak True\nassert result is False  # Tam olarak False\nassert result is None  # Tam olarak None\n\n# Üyelik\nassert item in collection\nassert item not in collection\n\n# Karşılaştırmalar\nassert result > 0\nassert 0 \u003C= result \u003C= 100\n\n# Tip kontrolü\nassert isinstance(result, str)\n\n# Exception testi (tercih edilen yaklaşım)\nwith pytest.raises(ValueError):\n    raise ValueError(\"error message\")\n\n# Exception mesajını kontrol et\nwith pytest.raises(ValueError, match=\"invalid input\"):\n    raise ValueError(\"invalid input provided\")\n\n# Exception niteliklerini kontrol et\nwith pytest.raises(ValueError) as exc_info:\n    raise ValueError(\"error message\")\nassert str(exc_info.value) == \"error message\"\n```\n\n## Fixture'lar\n\n### Temel Fixture Kullanımı\n\n```python\nimport pytest\n\n@pytest.fixture\ndef sample_data():\n    \"\"\"Örnek veri sağlayan fixture.\"\"\"\n    return {\"name\": \"Alice\", \"age\": 30}\n\ndef test_sample_data(sample_data):\n    \"\"\"Fixture kullanan test.\"\"\"\n    assert sample_data[\"name\"] == \"Alice\"\n    assert sample_data[\"age\"] == 30\n```\n\n### Setup\u002FTeardown ile Fixture\n\n```python\n@pytest.fixture\ndef database():\n    \"\"\"Setup ve teardown ile fixture.\"\"\"\n    # Setup\n    db = Database(\":memory:\")\n    db.create_tables()\n    db.insert_test_data()\n\n    yield db  # Teste sağla\n\n    # Teardown\n    db.close()\n\ndef test_database_query(database):\n    \"\"\"Veritabanı operasyonlarını test et.\"\"\"\n    result = database.query(\"SELECT * FROM users\")\n    assert len(result) > 0\n```\n\n### Fixture Scope'ları\n\n```python\n# Function scope (varsayılan) - her test için çalışır\n@pytest.fixture\ndef temp_file():\n    with open(\"temp.txt\", \"w\") as f:\n        yield f\n    os.remove(\"temp.txt\")\n\n# Module scope - modül başına bir kez çalışır\n@pytest.fixture(scope=\"module\")\ndef module_db():\n    db = Database(\":memory:\")\n    db.create_tables()\n    yield db\n    db.close()\n\n# Session scope - test oturumu başına bir kez çalışır\n@pytest.fixture(scope=\"session\")\ndef shared_resource():\n    resource = ExpensiveResource()\n    yield resource\n    resource.cleanup()\n```\n\n### Parametreli Fixture\n\n```python\n@pytest.fixture(params=[1, 2, 3])\ndef number(request):\n    \"\"\"Parametreli fixture.\"\"\"\n    return request.param\n\ndef test_numbers(number):\n    \"\"\"Test her parametre için 3 kez çalışır.\"\"\"\n    assert number > 0\n```\n\n### Birden Fazla Fixture Kullanma\n\n```python\n@pytest.fixture\ndef user():\n    return User(id=1, name=\"Alice\")\n\n@pytest.fixture\ndef admin():\n    return User(id=2, name=\"Admin\", role=\"admin\")\n\ndef test_user_admin_interaction(user, admin):\n    \"\"\"Birden fazla fixture kullanan test.\"\"\"\n    assert admin.can_manage(user)\n```\n\n### Autouse Fixture'ları\n\n```python\n@pytest.fixture(autouse=True)\ndef reset_config():\n    \"\"\"Her testten önce otomatik olarak çalışır.\"\"\"\n    Config.reset()\n    yield\n    Config.cleanup()\n\ndef test_without_fixture_call():\n    # reset_config otomatik olarak çalışır\n    assert Config.get_setting(\"debug\") is False\n```\n\n### Paylaşılan Fixture'lar için Conftest.py\n\n```python\n# tests\u002Fconftest.py\nimport pytest\n\n@pytest.fixture\ndef client():\n    \"\"\"Tüm testler için paylaşılan fixture.\"\"\"\n    app = create_app(testing=True)\n    with app.test_client() as client:\n        yield client\n\n@pytest.fixture\ndef auth_headers(client):\n    \"\"\"API testi için auth header'ları oluştur.\"\"\"\n    response = client.post(\"\u002Fapi\u002Flogin\", json={\n        \"username\": \"test\",\n        \"password\": \"test\"\n    })\n    token = response.json[\"token\"]\n    return {\"Authorization\": f\"Bearer {token}\"}\n```\n\n## Parametrizasyon\n\n### Temel Parametrizasyon\n\n```python\n@pytest.mark.parametrize(\"input,expected\", [\n    (\"hello\", \"HELLO\"),\n    (\"world\", \"WORLD\"),\n    (\"PyThOn\", \"PYTHON\"),\n])\ndef test_uppercase(input, expected):\n    \"\"\"Test farklı input'larla 3 kez çalışır.\"\"\"\n    assert input.upper() == expected\n```\n\n### Birden Fazla Parametre\n\n```python\n@pytest.mark.parametrize(\"a,b,expected\", [\n    (2, 3, 5),\n    (0, 0, 0),\n    (-1, 1, 0),\n    (100, 200, 300),\n])\ndef test_add(a, b, expected):\n    \"\"\"Birden fazla input ile toplama testi.\"\"\"\n    assert add(a, b) == expected\n```\n\n### ID'li Parametrizasyon\n\n```python\n@pytest.mark.parametrize(\"input,expected\", [\n    (\"valid@email.com\", True),\n    (\"invalid\", False),\n    (\"@no-domain.com\", False),\n], ids=[\"valid-email\", \"missing-at\", \"missing-domain\"])\ndef test_email_validation(input, expected):\n    \"\"\"Okunabilir test ID'leri ile email validation testi.\"\"\"\n    assert is_valid_email(input) is expected\n```\n\n### Parametreli Fixture'lar\n\n```python\n@pytest.fixture(params=[\"sqlite\", \"postgresql\", \"mysql\"])\ndef db(request):\n    \"\"\"Birden fazla veritabanı backend'ine karşı test.\"\"\"\n    if request.param == \"sqlite\":\n        return Database(\":memory:\")\n    elif request.param == \"postgresql\":\n        return Database(\"postgresql:\u002F\u002Flocalhost\u002Ftest\")\n    elif request.param == \"mysql\":\n        return Database(\"mysql:\u002F\u002Flocalhost\u002Ftest\")\n\ndef test_database_operations(db):\n    \"\"\"Test her veritabanı için 3 kez çalışır.\"\"\"\n    result = db.query(\"SELECT 1\")\n    assert result is not None\n```\n\n## Marker'lar ve Test Seçimi\n\n### Özel Marker'lar\n\n```python\n# Yavaş testleri işaretle\n@pytest.mark.slow\ndef test_slow_operation():\n    time.sleep(5)\n\n# Entegrasyon testlerini işaretle\n@pytest.mark.integration\ndef test_api_integration():\n    response = requests.get(\"https:\u002F\u002Fapi.example.com\")\n    assert response.status_code == 200\n\n# Unit testleri işaretle\n@pytest.mark.unit\ndef test_unit_logic():\n    assert calculate(2, 3) == 5\n```\n\n### Belirli Testleri Çalıştırma\n\n```bash\n# Sadece hızlı testleri çalıştır\npytest -m \"not slow\"\n\n# Sadece entegrasyon testlerini çalıştır\npytest -m integration\n\n# Entegrasyon veya yavaş testleri çalıştır\npytest -m \"integration or slow\"\n\n# Unit olarak işaretlenmiş ama yavaş olmayan testleri çalıştır\npytest -m \"unit and not slow\"\n```\n\n### pytest.ini'de Marker'ları Yapılandırma\n\n```ini\n[pytest]\nmarkers =\n    slow: marks tests as slow\n    integration: marks tests as integration tests\n    unit: marks tests as unit tests\n    django: marks tests as requiring Django\n```\n\n## Mocking ve Patching\n\n### Fonksiyonları Mocking\n\n```python\nfrom unittest.mock import patch, Mock\n\n@patch(\"mypackage.external_api_call\")\ndef test_with_mock(api_call_mock):\n    \"\"\"Mock'lanmış harici API ile test.\"\"\"\n    api_call_mock.return_value = {\"status\": \"success\"}\n\n    result = my_function()\n\n    api_call_mock.assert_called_once()\n    assert result[\"status\"] == \"success\"\n```\n\n### Dönüş Değerlerini Mocking\n\n```python\n@patch(\"mypackage.Database.connect\")\ndef test_database_connection(connect_mock):\n    \"\"\"Mock'lanmış veritabanı bağlantısı ile test.\"\"\"\n    connect_mock.return_value = MockConnection()\n\n    db = Database()\n    db.connect()\n\n    connect_mock.assert_called_once_with(\"localhost\")\n```\n\n### Exception'ları Mocking\n\n```python\n@patch(\"mypackage.api_call\")\ndef test_api_error_handling(api_call_mock):\n    \"\"\"Mock'lanmış exception ile hata işleme testi.\"\"\"\n    api_call_mock.side_effect = ConnectionError(\"Network error\")\n\n    with pytest.raises(ConnectionError):\n        api_call()\n\n    api_call_mock.assert_called_once()\n```\n\n### Context Manager'ları Mocking\n\n```python\n@patch(\"builtins.open\", new_callable=mock_open)\ndef test_file_reading(mock_file):\n    \"\"\"Mock'lanmış open ile dosya okuma testi.\"\"\"\n    mock_file.return_value.read.return_value = \"file content\"\n\n    result = read_file(\"test.txt\")\n\n    mock_file.assert_called_once_with(\"test.txt\", \"r\")\n    assert result == \"file content\"\n```\n\n### Autospec Kullanma\n\n```python\n@patch(\"mypackage.DBConnection\", autospec=True)\ndef test_autospec(db_mock):\n    \"\"\"API yanlış kullanımını yakalamak için autospec ile test.\"\"\"\n    db = db_mock.return_value\n    db.query(\"SELECT * FROM users\")\n\n    # DBConnection query metodu yoksa bu başarısız olur\n    db_mock.assert_called_once()\n```\n\n### Mock Class Instance'ları\n\n```python\nclass TestUserService:\n    @patch(\"mypackage.UserRepository\")\n    def test_create_user(self, repo_mock):\n        \"\"\"Mock'lanmış repository ile kullanıcı oluşturma testi.\"\"\"\n        repo_mock.return_value.save.return_value = User(id=1, name=\"Alice\")\n\n        service = UserService(repo_mock.return_value)\n        user = service.create_user(name=\"Alice\")\n\n        assert user.name == \"Alice\"\n        repo_mock.return_value.save.assert_called_once()\n```\n\n### Mock Property\n\n```python\n@pytest.fixture\ndef mock_config():\n    \"\"\"Property'li bir mock oluştur.\"\"\"\n    config = Mock()\n    type(config).debug = PropertyMock(return_value=True)\n    type(config).api_key = PropertyMock(return_value=\"test-key\")\n    return config\n\ndef test_with_mock_config(mock_config):\n    \"\"\"Mock'lanmış config property'leri ile test.\"\"\"\n    assert mock_config.debug is True\n    assert mock_config.api_key == \"test-key\"\n```\n\n## Asenkron Kodu Test Etme\n\n### pytest-asyncio ile Asenkron Testler\n\n```python\nimport pytest\n\n@pytest.mark.asyncio\nasync def test_async_function():\n    \"\"\"Asenkron fonksiyon testi.\"\"\"\n    result = await async_add(2, 3)\n    assert result == 5\n\n@pytest.mark.asyncio\nasync def test_async_with_fixture(async_client):\n    \"\"\"Asenkron fixture ile asenkron test.\"\"\"\n    response = await async_client.get(\"\u002Fapi\u002Fusers\")\n    assert response.status_code == 200\n```\n\n### Asenkron Fixture\n\n```python\n@pytest.fixture\nasync def async_client():\n    \"\"\"Asenkron test client sağlayan asenkron fixture.\"\"\"\n    app = create_app()\n    async with app.test_client() as client:\n        yield client\n\n@pytest.mark.asyncio\nasync def test_api_endpoint(async_client):\n    \"\"\"Asenkron fixture kullanan test.\"\"\"\n    response = await async_client.get(\"\u002Fapi\u002Fdata\")\n    assert response.status_code == 200\n```\n\n### Asenkron Fonksiyonları Mocking\n\n```python\n@pytest.mark.asyncio\n@patch(\"mypackage.async_api_call\")\nasync def test_async_mock(api_call_mock):\n    \"\"\"Mock ile asenkron fonksiyon testi.\"\"\"\n    api_call_mock.return_value = {\"status\": \"ok\"}\n\n    result = await my_async_function()\n\n    api_call_mock.assert_awaited_once()\n    assert result[\"status\"] == \"ok\"\n```\n\n## Exception'ları Test Etme\n\n### Beklenen Exception'ları Test Etme\n\n```python\ndef test_divide_by_zero():\n    \"\"\"Sıfıra bölmenin ZeroDivisionError raise ettiğini test et.\"\"\"\n    with pytest.raises(ZeroDivisionError):\n        divide(10, 0)\n\ndef test_custom_exception():\n    \"\"\"Mesaj ile özel exception testi.\"\"\"\n    with pytest.raises(ValueError, match=\"invalid input\"):\n        validate_input(\"invalid\")\n```\n\n### Exception Niteliklerini Test Etme\n\n```python\ndef test_exception_with_details():\n    \"\"\"Özel niteliklerle exception testi.\"\"\"\n    with pytest.raises(CustomError) as exc_info:\n        raise CustomError(\"error\", code=400)\n\n    assert exc_info.value.code == 400\n    assert \"error\" in str(exc_info.value)\n```\n\n## Yan Etkileri Test Etme\n\n### Dosya Operasyonlarını Test Etme\n\n```python\nimport tempfile\nimport os\n\ndef test_file_processing():\n    \"\"\"Geçici dosya ile dosya işleme testi.\"\"\"\n    with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt') as f:\n        f.write(\"test content\")\n        temp_path = f.name\n\n    try:\n        result = process_file(temp_path)\n        assert result == \"processed: test content\"\n    finally:\n        os.unlink(temp_path)\n```\n\n### pytest'in tmp_path Fixture'ı ile Test Etme\n\n```python\ndef test_with_tmp_path(tmp_path):\n    \"\"\"pytest'in built-in geçici yol fixture'ını kullanarak test.\"\"\"\n    test_file = tmp_path \u002F \"test.txt\"\n    test_file.write_text(\"hello world\")\n\n    result = process_file(str(test_file))\n    assert result == \"hello world\"\n    # tmp_path otomatik olarak temizlenir\n```\n\n### tmpdir Fixture ile Test Etme\n\n```python\ndef test_with_tmpdir(tmpdir):\n    \"\"\"pytest'in tmpdir fixture'ını kullanarak test.\"\"\"\n    test_file = tmpdir.join(\"test.txt\")\n    test_file.write(\"data\")\n\n    result = process_file(str(test_file))\n    assert result == \"data\"\n```\n\n## Test Organizasyonu\n\n### Dizin Yapısı\n\n```\ntests\u002F\n├── conftest.py                 # Paylaşılan fixture'lar\n├── __init__.py\n├── unit\u002F                       # Unit testler\n│   ├── __init__.py\n│   ├── test_models.py\n│   ├── test_utils.py\n│   └── test_services.py\n├── integration\u002F                # Entegrasyon testleri\n│   ├── __init__.py\n│   ├── test_api.py\n│   └── test_database.py\n└── e2e\u002F                        # End-to-end testler\n    ├── __init__.py\n    └── test_user_flow.py\n```\n\n### Test Class'ları\n\n```python\nclass TestUserService:\n    \"\"\"İlgili testleri bir class'ta grupla.\"\"\"\n\n    @pytest.fixture(autouse=True)\n    def setup(self):\n        \"\"\"Bu class'taki her testten önce çalışan setup.\"\"\"\n        self.service = UserService()\n\n    def test_create_user(self):\n        \"\"\"Kullanıcı oluşturma testi.\"\"\"\n        user = self.service.create_user(\"Alice\")\n        assert user.name == \"Alice\"\n\n    def test_delete_user(self):\n        \"\"\"Kullanıcı silme testi.\"\"\"\n        user = User(id=1, name=\"Bob\")\n        self.service.delete_user(user)\n        assert not self.service.user_exists(1)\n```\n\n## En İyi Uygulamalar\n\n### YAPIN\n\n- **TDD'yi takip edin**: Koddan önce testleri yazın (red-green-refactor)\n- **Bir şeyi test edin**: Her test tek bir davranışı doğrulamalı\n- **Açıklayıcı isimler kullanın**: `test_user_login_with_invalid_credentials_fails`\n- **Fixture'ları kullanın**: Tekrarı fixture'larla ortadan kaldırın\n- **Harici bağımlılıkları mock'layın**: Harici servislere bağımlı olmayın\n- **Kenar durumları test edin**: Boş input'lar, None değerleri, sınır koşulları\n- **%80+ coverage hedefleyin**: Kritik yollara odaklanın\n- **Testleri hızlı tutun**: Yavaş testleri ayırmak için marker'lar kullanın\n\n### YAPMAYIN\n\n- **İmplementasyonu test etmeyin**: Davranışı test edin, iç yapıyı değil\n- **Testlerde karmaşık koşullar kullanmayın**: Testleri basit tutun\n- **Test hatalarını göz ardı etmeyin**: Tüm testler geçmeli\n- **Third-party kodu test etmeyin**: Kütüphanelerin çalıştığına güvenin\n- **Testler arası state paylaşmayın**: Testler bağımsız olmalı\n- **Testlerde exception yakalamayın**: `pytest.raises` kullanın\n- **Print statement'ları kullanmayın**: Assertion'ları ve pytest çıktısını kullanın\n- **Çok kırılgan testler yazmayın**: Aşırı spesifik mock'lardan kaçının\n\n## Yaygın Desenler\n\n### API Endpoint'lerini Test Etme (FastAPI\u002FFlask)\n\n```python\n@pytest.fixture\ndef client():\n    app = create_app(testing=True)\n    return app.test_client()\n\ndef test_get_user(client):\n    response = client.get(\"\u002Fapi\u002Fusers\u002F1\")\n    assert response.status_code == 200\n    assert response.json[\"id\"] == 1\n\ndef test_create_user(client):\n    response = client.post(\"\u002Fapi\u002Fusers\", json={\n        \"name\": \"Alice\",\n        \"email\": \"alice@example.com\"\n    })\n    assert response.status_code == 201\n    assert response.json[\"name\"] == \"Alice\"\n```\n\n### Veritabanı Operasyonlarını Test Etme\n\n```python\n@pytest.fixture\ndef db_session():\n    \"\"\"Test veritabanı oturumu oluştur.\"\"\"\n    session = Session(bind=engine)\n    session.begin_nested()\n    yield session\n    session.rollback()\n    session.close()\n\ndef test_create_user(db_session):\n    user = User(name=\"Alice\", email=\"alice@example.com\")\n    db_session.add(user)\n    db_session.commit()\n\n    retrieved = db_session.query(User).filter_by(name=\"Alice\").first()\n    assert retrieved.email == \"alice@example.com\"\n```\n\n### Class Metodlarını Test Etme\n\n```python\nclass TestCalculator:\n    @pytest.fixture\n    def calculator(self):\n        return Calculator()\n\n    def test_add(self, calculator):\n        assert calculator.add(2, 3) == 5\n\n    def test_divide_by_zero(self, calculator):\n        with pytest.raises(ZeroDivisionError):\n            calculator.divide(10, 0)\n```\n\n## pytest Yapılandırması\n\n### pytest.ini\n\n```ini\n[pytest]\ntestpaths = tests\npython_files = test_*.py\npython_classes = Test*\npython_functions = test_*\naddopts =\n    --strict-markers\n    --disable-warnings\n    --cov=mypackage\n    --cov-report=term-missing\n    --cov-report=html\nmarkers =\n    slow: marks tests as slow\n    integration: marks tests as integration tests\n    unit: marks tests as unit tests\n```\n\n### pyproject.toml\n\n```toml\n[tool.pytest.ini_options]\ntestpaths = [\"tests\"]\npython_files = [\"test_*.py\"]\npython_classes = [\"Test*\"]\npython_functions = [\"test_*\"]\naddopts = [\n    \"--strict-markers\",\n    \"--cov=mypackage\",\n    \"--cov-report=term-missing\",\n    \"--cov-report=html\",\n]\nmarkers = [\n    \"slow: marks tests as slow\",\n    \"integration: marks tests as integration tests\",\n    \"unit: marks tests as unit tests\",\n]\n```\n\n## Testleri Çalıştırma\n\n```bash\n# Tüm testleri çalıştır\npytest\n\n# Belirli dosyayı çalıştır\npytest tests\u002Ftest_utils.py\n\n# Belirli testi çalıştır\npytest tests\u002Ftest_utils.py::test_function\n\n# Verbose çıktı ile çalıştır\npytest -v\n\n# Coverage ile çalıştır\npytest --cov=mypackage --cov-report=html\n\n# Sadece hızlı testleri çalıştır\npytest -m \"not slow\"\n\n# İlk hataya kadar çalıştır\npytest -x\n\n# N hataya kadar çalıştır\npytest --maxfail=3\n\n# Son başarısız testleri çalıştır\npytest --lf\n\n# Pattern ile testleri çalıştır\npytest -k \"test_user\"\n\n# Hatada debugger ile çalıştır\npytest --pdb\n```\n\n## Hızlı Referans\n\n| Desen | Kullanım |\n|-------|----------|\n| `pytest.raises()` | Beklenen exception'ları test et |\n| `@pytest.fixture()` | Yeniden kullanılabilir test fixture'ları oluştur |\n| `@pytest.mark.parametrize()` | Birden fazla input ile testleri çalıştır |\n| `@pytest.mark.slow` | Yavaş testleri işaretle |\n| `pytest -m \"not slow\"` | Yavaş testleri atla |\n| `@patch()` | Fonksiyonları ve class'ları mock'la |\n| `tmp_path` fixture | Otomatik geçici dizin |\n| `pytest --cov` | Coverage raporu oluştur |\n| `assert` | Basit ve okunabilir assertion'lar |\n\n**Unutmayın**: Testler de koddur. Temiz, okunabilir ve bakımı kolay tutun. İyi testler hata yakalar; harika testler hataları önler.\n","# Python Test Desenleri\n\npytest, TDD metodolojisi ve en iyi uygulamalar kullanarak Python uygulamaları için kapsamlı test stratejileri.\n\n## Ne Zaman Etkinleştirmeli\n\n- Yeni Python kodu yazarken (TDD'yi takip et: red, green, refactor)\n- Python projeleri için test suite'leri tasarlarken\n- Python test coverage'ını gözden geçirirken\n- Test altyapısını kurarken\n\n## Temel Test Felsefesi\n\n### Test-Driven Development (TDD)\n\nHer zaman TDD döngüsünü takip edin:\n\n1. **RED**: İstenen davranış için başarısız bir test yaz\n2. **GREEN**: Testi geçirmek için minimal kod yaz\n3. **REFACTOR**: Testleri yeşil tutarken kodu iyileştir\n\n```python\n# Adım 1: Başarısız test yaz (RED)\ndef test_add_numbers():\n    result = add(2, 3)\n    assert result == 5\n\n# Adım 2: Minimal implementasyon yaz (GREEN)\ndef add(a, b):\n    return a + b\n\n# Adım 3: Gerekirse refactor et (REFACTOR)\n```\n\n### Coverage Gereksinimleri\n\n- **Hedef**: 80%+ kod coverage'ı\n- **Kritik yollar**: 100% coverage gereklidir\n- Coverage'ı ölçmek için `pytest --cov` kullanın\n\n```bash\npytest --cov=mypackage --cov-report=term-missing --cov-report=html\n```\n\n## pytest Temelleri\n\n### Temel Test Yapısı\n\n```python\nimport pytest\n\ndef test_addition():\n    \"\"\"Temel toplama testi.\"\"\"\n    assert 2 + 2 == 4\n\ndef test_string_uppercase():\n    \"\"\"String büyük harf yapma testi.\"\"\"\n    text = \"hello\"\n    assert text.upper() == \"HELLO\"\n\ndef test_list_append():\n    \"\"\"Liste append testi.\"\"\"\n    items = [1, 2, 3]\n    items.append(4)\n    assert 4 in items\n    assert len(items) == 4\n```\n\n### Assertion'lar\n\n```python\n# Eşitlik\nassert result == expected\n\n# Eşitsizlik\nassert result != unexpected\n\n# Doğruluk değeri\nassert result  # Truthy\nassert not result  # Falsy\nassert result is True  # Tam olarak True\nassert result is False  # Tam olarak False\nassert result is None  # Tam olarak None\n\n# Üyelik\nassert item in collection\nassert item not in collection\n\n# Karşılaştırmalar\nassert result > 0\nassert 0 \u003C= result \u003C= 100\n\n# Tip kontrolü\nassert isinstance(result, str)\n\n# Exception testi (tercih edilen yaklaşım)\nwith pytest.raises(ValueError):\n    raise ValueError(\"error message\")\n\n# Exception mesajını kontrol et\nwith pytest.raises(ValueError, match=\"invalid input\"):\n    raise ValueError(\"invalid input provided\")\n\n# Exception niteliklerini kontrol et\nwith pytest.raises(ValueError) as exc_info:\n    raise ValueError(\"error message\")\nassert str(exc_info.value) == \"error message\"\n```\n\n## Fixture'lar\n\n### Temel Fixture Kullanımı\n\n```python\nimport pytest\n\n@pytest.fixture\ndef sample_data():\n    \"\"\"Örnek veri sağlayan fixture.\"\"\"\n    return {\"name\": \"Alice\", \"age\": 30}\n\ndef test_sample_data(sample_data):\n    \"\"\"Fixture kullanan test.\"\"\"\n    assert sample_data[\"name\"] == \"Alice\"\n    assert sample_data[\"age\"] == 30\n```\n\n### Setup\u002FTeardown ile Fixture\n\n```python\n@pytest.fixture\ndef database():\n    \"\"\"Setup ve teardown ile fixture.\"\"\"\n    # Setup\n    db = Database(\":memory:\")\n    db.create_tables()\n    db.insert_test_data()\n\n    yield db  # Teste sağla\n\n    # Teardown\n    db.close()\n\ndef test_database_query(database):\n    \"\"\"Veritabanı operasyonlarını test et.\"\"\"\n    result = database.query(\"SELECT * FROM users\")\n    assert len(result) > 0\n```\n\n### Fixture Scope'ları\n\n```python\n# Function scope (varsayılan) - her test için çalışır\n@pytest.fixture\ndef temp_file():\n    with open(\"temp.txt\", \"w\") as f:\n        yield f\n    os.remove(\"temp.txt\")\n\n# Module scope - modül başına bir kez çalışır\n@pytest.fixture(scope=\"module\")\ndef module_db():\n    db = Database(\":memory:\")\n    db.create_tables()\n    yield db\n    db.close()\n\n# Session scope - test oturumu başına bir kez çalışır\n@pytest.fixture(scope=\"session\")\ndef shared_resource():\n    resource = ExpensiveResource()\n    yield resource\n    resource.cleanup()\n```\n\n### Parametreli Fixture\n\n```python\n@pytest.fixture(params=[1, 2, 3])\ndef number(request):\n    \"\"\"Parametreli fixture.\"\"\"\n    return request.param\n\ndef test_numbers(number):\n    \"\"\"Test her parametre için 3 kez çalışır.\"\"\"\n    assert number > 0\n```\n\n### Birden Fazla Fixture Kullanma\n\n```python\n@pytest.fixture\ndef user():\n    return User(id=1, name=\"Alice\")\n\n@pytest.fixture\ndef admin():\n    return User(id=2, name=\"Admin\", role=\"admin\")\n\ndef test_user_admin_interaction(user, admin):\n    \"\"\"Birden fazla fixture kullanan test.\"\"\"\n    assert admin.can_manage(user)\n```\n\n### Autouse Fixture'ları\n\n```python\n@pytest.fixture(autouse=True)\ndef reset_config():\n    \"\"\"Her testten önce otomatik olarak çalışır.\"\"\"\n    Config.reset()\n    yield\n    Config.cleanup()\n\ndef test_without_fixture_call():\n    # reset_config otomatik olarak çalışır\n    assert Config.get_setting(\"debug\") is False\n```\n\n### Paylaşılan Fixture'lar için Conftest.py\n\n```python\n# tests\u002Fconftest.py\nimport pytest\n\n@pytest.fixture\ndef client():\n    \"\"\"Tüm testler için paylaşılan fixture.\"\"\"\n    app = create_app(testing=True)\n    with app.test_client() as client:\n        yield client\n\n@pytest.fixture\ndef auth_headers(client):\n    \"\"\"API testi için auth header'ları oluştur.\"\"\"\n    response = client.post(\"\u002Fapi\u002Flogin\", json={\n        \"username\": \"test\",\n        \"password\": \"test\"\n    })\n    token = response.json[\"token\"]\n    return {\"Authorization\": f\"Bearer {token}\"}\n```\n\n## Parametrizasyon\n\n### Temel Parametrizasyon\n\n```python\n@pytest.mark.parametrize(\"input,expected\", [\n    (\"hello\", \"HELLO\"),\n    (\"world\", \"WORLD\"),\n    (\"PyThOn\", \"PYTHON\"),\n])\ndef test_uppercase(input, expected):\n    \"\"\"Test farklı input'larla 3 kez çalışır.\"\"\"\n    assert input.upper() == expected\n```\n\n### Birden Fazla Parametre\n\n```python\n@pytest.mark.parametrize(\"a,b,expected\", [\n    (2, 3, 5),\n    (0, 0, 0),\n    (-1, 1, 0),\n    (100, 200, 300),\n])\ndef test_add(a, b, expected):\n    \"\"\"Birden fazla input ile toplama testi.\"\"\"\n    assert add(a, b) == expected\n```\n\n### ID'li Parametrizasyon\n\n```python\n@pytest.mark.parametrize(\"input,expected\", [\n    (\"valid@email.com\", True),\n    (\"invalid\", False),\n    (\"@no-domain.com\", False),\n], ids=[\"valid-email\", \"missing-at\", \"missing-domain\"])\ndef test_email_validation(input, expected):\n    \"\"\"Okunabilir test ID'leri ile email validation testi.\"\"\"\n    assert is_valid_email(input) is expected\n```\n\n### Parametreli Fixture'lar\n\n```python\n@pytest.fixture(params=[\"sqlite\", \"postgresql\", \"mysql\"])\ndef db(request):\n    \"\"\"Birden fazla veritabanı backend'ine karşı test.\"\"\"\n    if request.param == \"sqlite\":\n        return Database(\":memory:\")\n    elif request.param == \"postgresql\":\n        return Database(\"postgresql:\u002F\u002Flocalhost\u002Ftest\")\n    elif request.param == \"mysql\":\n        return Database(\"mysql:\u002F\u002Flocalhost\u002Ftest\")\n\ndef test_database_operations(db):\n    \"\"\"Test her veritabanı için 3 kez çalışır.\"\"\"\n    result = db.query(\"SELECT 1\")\n    assert result is not None\n```\n\n## Marker'lar ve Test Seçimi\n\n### Özel Marker'lar\n\n```python\n# Yavaş testleri işaretle\n@pytest.mark.slow\ndef test_slow_operation():\n    time.sleep(5)\n\n# Entegrasyon testlerini işaretle\n@pytest.mark.integration\ndef test_api_integration():\n    response = requests.get(\"https:\u002F\u002Fapi.example.com\")\n    assert response.status_code == 200\n\n# Unit testleri işaretle\n@pytest.mark.unit\ndef test_unit_logic():\n    assert calculate(2, 3) == 5\n```\n\n### Belirli Testleri Çalıştırma\n\n```bash\n# Sadece hızlı testleri çalıştır\npytest -m \"not slow\"\n\n# Sadece entegrasyon testlerini çalıştır\npytest -m integration\n\n# Entegrasyon veya yavaş testleri çalıştır\npytest -m \"integration or slow\"\n\n# Unit olarak işaretlenmiş ama yavaş olmayan testleri çalıştır\npytest -m \"unit and not slow\"\n```\n\n### pytest.ini'de Marker'ları Yapılandırma\n\n```ini\n[pytest]\nmarkers =\n    slow: marks tests as slow\n    integration: marks tests as integration tests\n    unit: marks tests as unit tests\n    django: marks tests as requiring Django\n```\n\n## Mocking ve Patching\n\n### Fonksiyonları Mocking\n\n```python\nfrom unittest.mock import patch, Mock\n\n@patch(\"mypackage.external_api_call\")\ndef test_with_mock(api_call_mock):\n    \"\"\"Mock'lanmış harici API ile test.\"\"\"\n    api_call_mock.return_value = {\"status\": \"success\"}\n\n    result = my_function()\n\n    api_call_mock.assert_called_once()\n    assert result[\"status\"] == \"success\"\n```\n\n### Dönüş Değerlerini Mocking\n\n```python\n@patch(\"mypackage.Database.connect\")\ndef test_database_connection(connect_mock):\n    \"\"\"Mock'lanmış veritabanı bağlantısı ile test.\"\"\"\n    connect_mock.return_value = MockConnection()\n\n    db = Database()\n    db.connect()\n\n    connect_mock.assert_called_once_with(\"localhost\")\n```\n\n### Exception'ları Mocking\n\n```python\n@patch(\"mypackage.api_call\")\ndef test_api_error_handling(api_call_mock):\n    \"\"\"Mock'lanmış exception ile hata işleme testi.\"\"\"\n    api_call_mock.side_effect = ConnectionError(\"Network error\")\n\n    with pytest.raises(ConnectionError):\n        api_call()\n\n    api_call_mock.assert_called_once()\n```\n\n### Context Manager'ları Mocking\n\n```python\n@patch(\"builtins.open\", new_callable=mock_open)\ndef test_file_reading(mock_file):\n    \"\"\"Mock'lanmış open ile dosya okuma testi.\"\"\"\n    mock_file.return_value.read.return_value = \"file content\"\n\n    result = read_file(\"test.txt\")\n\n    mock_file.assert_called_once_with(\"test.txt\", \"r\")\n    assert result == \"file content\"\n```\n\n### Autospec Kullanma\n\n```python\n@patch(\"mypackage.DBConnection\", autospec=True)\ndef test_autospec(db_mock):\n    \"\"\"API yanlış kullanımını yakalamak için autospec ile test.\"\"\"\n    db = db_mock.return_value\n    db.query(\"SELECT * FROM users\")\n\n    # DBConnection query metodu yoksa bu başarısız olur\n    db_mock.assert_called_once()\n```\n\n### Mock Class Instance'ları\n\n```python\nclass TestUserService:\n    @patch(\"mypackage.UserRepository\")\n    def test_create_user(self, repo_mock):\n        \"\"\"Mock'lanmış repository ile kullanıcı oluşturma testi.\"\"\"\n        repo_mock.return_value.save.return_value = User(id=1, name=\"Alice\")\n\n        service = UserService(repo_mock.return_value)\n        user = service.create_user(name=\"Alice\")\n\n        assert user.name == \"Alice\"\n        repo_mock.return_value.save.assert_called_once()\n```\n\n### Mock Property\n\n```python\n@pytest.fixture\ndef mock_config():\n    \"\"\"Property'li bir mock oluştur.\"\"\"\n    config = Mock()\n    type(config).debug = PropertyMock(return_value=True)\n    type(config).api_key = PropertyMock(return_value=\"test-key\")\n    return config\n\ndef test_with_mock_config(mock_config):\n    \"\"\"Mock'lanmış config property'leri ile test.\"\"\"\n    assert mock_config.debug is True\n    assert mock_config.api_key == \"test-key\"\n```\n\n## Asenkron Kodu Test Etme\n\n### pytest-asyncio ile Asenkron Testler\n\n```python\nimport pytest\n\n@pytest.mark.asyncio\nasync def test_async_function():\n    \"\"\"Asenkron fonksiyon testi.\"\"\"\n    result = await async_add(2, 3)\n    assert result == 5\n\n@pytest.mark.asyncio\nasync def test_async_with_fixture(async_client):\n    \"\"\"Asenkron fixture ile asenkron test.\"\"\"\n    response = await async_client.get(\"\u002Fapi\u002Fusers\")\n    assert response.status_code == 200\n```\n\n### Asenkron Fixture\n\n```python\n@pytest.fixture\nasync def async_client():\n    \"\"\"Asenkron test client sağlayan asenkron fixture.\"\"\"\n    app = create_app()\n    async with app.test_client() as client:\n        yield client\n\n@pytest.mark.asyncio\nasync def test_api_endpoint(async_client):\n    \"\"\"Asenkron fixture kullanan test.\"\"\"\n    response = await async_client.get(\"\u002Fapi\u002Fdata\")\n    assert response.status_code == 200\n```\n\n### Asenkron Fonksiyonları Mocking\n\n```python\n@pytest.mark.asyncio\n@patch(\"mypackage.async_api_call\")\nasync def test_async_mock(api_call_mock):\n    \"\"\"Mock ile asenkron fonksiyon testi.\"\"\"\n    api_call_mock.return_value = {\"status\": \"ok\"}\n\n    result = await my_async_function()\n\n    api_call_mock.assert_awaited_once()\n    assert result[\"status\"] == \"ok\"\n```\n\n## Exception'ları Test Etme\n\n### Beklenen Exception'ları Test Etme\n\n```python\ndef test_divide_by_zero():\n    \"\"\"Sıfıra bölmenin ZeroDivisionError raise ettiğini test et.\"\"\"\n    with pytest.raises(ZeroDivisionError):\n        divide(10, 0)\n\ndef test_custom_exception():\n    \"\"\"Mesaj ile özel exception testi.\"\"\"\n    with pytest.raises(ValueError, match=\"invalid input\"):\n        validate_input(\"invalid\")\n```\n\n### Exception Niteliklerini Test Etme\n\n```python\ndef test_exception_with_details():\n    \"\"\"Özel niteliklerle exception testi.\"\"\"\n    with pytest.raises(CustomError) as exc_info:\n        raise CustomError(\"error\", code=400)\n\n    assert exc_info.value.code == 400\n    assert \"error\" in str(exc_info.value)\n```\n\n## Yan Etkileri Test Etme\n\n### Dosya Operasyonlarını Test Etme\n\n```python\nimport tempfile\nimport os\n\ndef test_file_processing():\n    \"\"\"Geçici dosya ile dosya işleme testi.\"\"\"\n    with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt') as f:\n        f.write(\"test content\")\n        temp_path = f.name\n\n    try:\n        result = process_file(temp_path)\n        assert result == \"processed: test content\"\n    finally:\n        os.unlink(temp_path)\n```\n\n### pytest'in tmp_path Fixture'ı ile Test Etme\n\n```python\ndef test_with_tmp_path(tmp_path):\n    \"\"\"pytest'in built-in geçici yol fixture'ını kullanarak test.\"\"\"\n    test_file = tmp_path \u002F \"test.txt\"\n    test_file.write_text(\"hello world\")\n\n    result = process_file(str(test_file))\n    assert result == \"hello world\"\n    # tmp_path otomatik olarak temizlenir\n```\n\n### tmpdir Fixture ile Test Etme\n\n```python\ndef test_with_tmpdir(tmpdir):\n    \"\"\"pytest'in tmpdir fixture'ını kullanarak test.\"\"\"\n    test_file = tmpdir.join(\"test.txt\")\n    test_file.write(\"data\")\n\n    result = process_file(str(test_file))\n    assert result == \"data\"\n```\n\n## Test Organizasyonu\n\n### Dizin Yapısı\n\n```\ntests\u002F\n├── conftest.py                 # Paylaşılan fixture'lar\n├── __init__.py\n├── unit\u002F                       # Unit testler\n│   ├── __init__.py\n│   ├── test_models.py\n│   ├── test_utils.py\n│   └── test_services.py\n├── integration\u002F                # Entegrasyon testleri\n│   ├── __init__.py\n│   ├── test_api.py\n│   └── test_database.py\n└── e2e\u002F                        # End-to-end testler\n    ├── __init__.py\n    └── test_user_flow.py\n```\n\n### Test Class'ları\n\n```python\nclass TestUserService:\n    \"\"\"İlgili testleri bir class'ta grupla.\"\"\"\n\n    @pytest.fixture(autouse=True)\n    def setup(self):\n        \"\"\"Bu class'taki her testten önce çalışan setup.\"\"\"\n        self.service = UserService()\n\n    def test_create_user(self):\n        \"\"\"Kullanıcı oluşturma testi.\"\"\"\n        user = self.service.create_user(\"Alice\")\n        assert user.name == \"Alice\"\n\n    def test_delete_user(self):\n        \"\"\"Kullanıcı silme testi.\"\"\"\n        user = User(id=1, name=\"Bob\")\n        self.service.delete_user(user)\n        assert not self.service.user_exists(1)\n```\n\n## En İyi Uygulamalar\n\n### YAPIN\n\n- **TDD'yi takip edin**: Koddan önce testleri yazın (red-green-refactor)\n- **Bir şeyi test edin**: Her test tek bir davranışı doğrulamalı\n- **Açıklayıcı isimler kullanın**: `test_user_login_with_invalid_credentials_fails`\n- **Fixture'ları kullanın**: Tekrarı fixture'larla ortadan kaldırın\n- **Harici bağımlılıkları mock'layın**: Harici servislere bağımlı olmayın\n- **Kenar durumları test edin**: Boş input'lar, None değerleri, sınır koşulları\n- **%80+ coverage hedefleyin**: Kritik yollara odaklanın\n- **Testleri hızlı tutun**: Yavaş testleri ayırmak için marker'lar kullanın\n\n### YAPMAYIN\n\n- **İmplementasyonu test etmeyin**: Davranışı test edin, iç yapıyı değil\n- **Testlerde karmaşık koşullar kullanmayın**: Testleri basit tutun\n- **Test hatalarını göz ardı etmeyin**: Tüm testler geçmeli\n- **Third-party kodu test etmeyin**: Kütüphanelerin çalıştığına güvenin\n- **Testler arası state paylaşmayın**: Testler bağımsız olmalı\n- **Testlerde exception yakalamayın**: `pytest.raises` kullanın\n- **Print statement'ları kullanmayın**: Assertion'ları ve pytest çıktısını kullanın\n- **Çok kırılgan testler yazmayın**: Aşırı spesifik mock'lardan kaçının\n\n## Yaygın Desenler\n\n### API Endpoint'lerini Test Etme (FastAPI\u002FFlask)\n\n```python\n@pytest.fixture\ndef client():\n    app = create_app(testing=True)\n    return app.test_client()\n\ndef test_get_user(client):\n    response = client.get(\"\u002Fapi\u002Fusers\u002F1\")\n    assert response.status_code == 200\n    assert response.json[\"id\"] == 1\n\ndef test_create_user(client):\n    response = client.post(\"\u002Fapi\u002Fusers\", json={\n        \"name\": \"Alice\",\n        \"email\": \"alice@example.com\"\n    })\n    assert response.status_code == 201\n    assert response.json[\"name\"] == \"Alice\"\n```\n\n### Veritabanı Operasyonlarını Test Etme\n\n```python\n@pytest.fixture\ndef db_session():\n    \"\"\"Test veritabanı oturumu oluştur.\"\"\"\n    session = Session(bind=engine)\n    session.begin_nested()\n    yield session\n    session.rollback()\n    session.close()\n\ndef test_create_user(db_session):\n    user = User(name=\"Alice\", email=\"alice@example.com\")\n    db_session.add(user)\n    db_session.commit()\n\n    retrieved = db_session.query(User).filter_by(name=\"Alice\").first()\n    assert retrieved.email == \"alice@example.com\"\n```\n\n### Class Metodlarını Test Etme\n\n```python\nclass TestCalculator:\n    @pytest.fixture\n    def calculator(self):\n        return Calculator()\n\n    def test_add(self, calculator):\n        assert calculator.add(2, 3) == 5\n\n    def test_divide_by_zero(self, calculator):\n        with pytest.raises(ZeroDivisionError):\n            calculator.divide(10, 0)\n```\n\n## pytest Yapılandırması\n\n### pytest.ini\n\n```ini\n[pytest]\ntestpaths = tests\npython_files = test_*.py\npython_classes = Test*\npython_functions = test_*\naddopts =\n    --strict-markers\n    --disable-warnings\n    --cov=mypackage\n    --cov-report=term-missing\n    --cov-report=html\nmarkers =\n    slow: marks tests as slow\n    integration: marks tests as integration tests\n    unit: marks tests as unit tests\n```\n\n### pyproject.toml\n\n```toml\n[tool.pytest.ini_options]\ntestpaths = [\"tests\"]\npython_files = [\"test_*.py\"]\npython_classes = [\"Test*\"]\npython_functions = [\"test_*\"]\naddopts = [\n    \"--strict-markers\",\n    \"--cov=mypackage\",\n    \"--cov-report=term-missing\",\n    \"--cov-report=html\",\n]\nmarkers = [\n    \"slow: marks tests as slow\",\n    \"integration: marks tests as integration tests\",\n    \"unit: marks tests as unit tests\",\n]\n```\n\n## Testleri Çalıştırma\n\n```bash\n# Tüm testleri çalıştır\npytest\n\n# Belirli dosyayı çalıştır\npytest tests\u002Ftest_utils.py\n\n# Belirli testi çalıştır\npytest tests\u002Ftest_utils.py::test_function\n\n# Verbose çıktı ile çalıştır\npytest -v\n\n# Coverage ile çalıştır\npytest --cov=mypackage --cov-report=html\n\n# Sadece hızlı testleri çalıştır\npytest -m \"not slow\"\n\n# İlk hataya kadar çalıştır\npytest -x\n\n# N hataya kadar çalıştır\npytest --maxfail=3\n\n# Son başarısız testleri çalıştır\npytest --lf\n\n# Pattern ile testleri çalıştır\npytest -k \"test_user\"\n\n# Hatada debugger ile çalıştır\npytest --pdb\n```\n\n## Hızlı Referans\n\n| Desen | Kullanım |\n|-------|----------|\n| `pytest.raises()` | Beklenen exception'ları test et |\n| `@pytest.fixture()` | Yeniden kullanılabilir test fixture'ları oluştur |\n| `@pytest.mark.parametrize()` | Birden fazla input ile testleri çalıştır |\n| `@pytest.mark.slow` | Yavaş testleri işaretle |\n| `pytest -m \"not slow\"` | Yavaş testleri atla |\n| `@patch()` | Fonksiyonları ve class'ları mock'la |\n| `tmp_path` fixture | Otomatik geçici dizin |\n| `pytest --cov` | Coverage raporu oluştur |\n| `assert` | Basit ve okunabilir assertion'lar |\n\n**Unutmayın**: Testler de koddur. Temiz, okunabilir ve bakımı kolay tutun. İyi testler hata yakalar; harika testler hataları önler.\n",{"name":5,"origin":24,"description":7},"ECC","main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-AI-应用工具\u002FYYC3-AI-应用工具-Everything-claude-code\u002Fdocs\u002Ftr\u002Fskills\u002Fpython-testing",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill python-testing",{"tool":40,"command":41},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill python-testing",{"tool":43,"command":44},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill python-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-Everything-claude-code\u002Fdocs\u002Ftr\u002Fskills\u002Fpython-testing\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]