pytest-llm-assert 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/PKG-INFO +1 -1
  2. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/pyproject.toml +1 -1
  3. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/src/pytest_llm_assert/core.py +23 -24
  4. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/uv.lock +1 -1
  5. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.env.example +0 -0
  6. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/CODEOWNERS +0 -0
  7. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  8. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  9. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  10. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  11. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/dependabot.yml +0 -0
  12. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/workflows/ci.yml +0 -0
  13. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/workflows/codeql.yml +0 -0
  14. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/workflows/dependency-review.yml +0 -0
  15. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/workflows/release.yml +0 -0
  16. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.github/workflows/stale.yml +0 -0
  17. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.gitignore +0 -0
  18. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/.pre-commit-config.yaml +0 -0
  19. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/CODE_OF_CONDUCT.md +0 -0
  20. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/CONTRIBUTING.md +0 -0
  21. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/LICENSE +0 -0
  22. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/README.md +0 -0
  23. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/SECURITY.md +0 -0
  24. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/docs/GITHUB_SETUP_GUIDE.md +0 -0
  25. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/docs/README.md +0 -0
  26. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/docs/api-reference.md +0 -0
  27. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/docs/comparing-models.md +0 -0
  28. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/docs/configuration.md +0 -0
  29. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/examples/README.md +0 -0
  30. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/examples/conftest.py +0 -0
  31. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/examples/pytest_conftest.py +0 -0
  32. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/examples/test_basic.py +0 -0
  33. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/examples/test_compare_models.py +0 -0
  34. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/src/pytest_llm_assert/__init__.py +0 -0
  35. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/src/pytest_llm_assert/plugin.py +0 -0
  36. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/src/pytest_llm_assert/prompts/system_prompt.md +0 -0
  37. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/__init__.py +0 -0
  38. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/integration/__init__.py +0 -0
  39. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/integration/test_llm_integration.py +0 -0
  40. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/__init__.py +0 -0
  41. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_assertion_result.py +0 -0
  42. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_azure_auth.py +0 -0
  43. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_error_handling.py +0 -0
  44. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_fixture_integration.py +0 -0
  45. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_llm_assert_core.py +0 -0
  46. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_llm_response.py +0 -0
  47. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_plugin.py +0 -0
  48. {pytest_llm_assert-0.2.0 → pytest_llm_assert-0.2.1}/tests/unit/test_response_parsing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-llm-assert
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Simple LLM-powered assertions for any pytest test
5
5
  Project-URL: Homepage, https://github.com/sbroenne/pytest-llm-assert
6
6
  Project-URL: Documentation, https://github.com/sbroenne/pytest-llm-assert#readme
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pytest-llm-assert"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "Simple LLM-powered assertions for any pytest test"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import functools
5
6
  import json
6
7
  import os
7
8
  import re
@@ -19,6 +20,27 @@ if TYPE_CHECKING:
19
20
  from typing import Any
20
21
 
21
22
 
23
+ @functools.cache
24
+ def _get_azure_ad_token_provider() -> Callable[[], str] | None:
25
+ """Get Azure AD token provider for Entra ID authentication.
26
+
27
+ Uses LiteLLM's built-in helper which leverages DefaultAzureCredential.
28
+ Cached at module level to avoid recreating credentials on each call.
29
+ """
30
+ try:
31
+ from litellm.secret_managers.get_azure_ad_token_provider import (
32
+ get_azure_ad_token_provider,
33
+ )
34
+
35
+ return get_azure_ad_token_provider()
36
+ except ImportError:
37
+ # azure-identity not installed
38
+ return None
39
+ except Exception:
40
+ # Credential not available
41
+ return None
42
+
43
+
22
44
  @dataclass(slots=True)
23
45
  class LLMResponse:
24
46
  """Response details from the last LLM call.
@@ -93,7 +115,7 @@ class LLMAssert:
93
115
 
94
116
  # Auto-configure Azure Entra ID when no API key is provided
95
117
  if self._is_azure_model() and not self._has_azure_api_key():
96
- self._azure_ad_token_provider = self._get_azure_ad_token_provider()
118
+ self._azure_ad_token_provider = _get_azure_ad_token_provider()
97
119
 
98
120
  def _is_azure_model(self) -> bool:
99
121
  """Check if the model is an Azure OpenAI model."""
@@ -103,29 +125,6 @@ class LLMAssert:
103
125
  """Check if an Azure API key is available."""
104
126
  return bool(self.api_key or os.environ.get("AZURE_API_KEY"))
105
127
 
106
- @staticmethod
107
- def _get_azure_ad_token_provider() -> Callable[[], str] | None:
108
- """Get Azure AD token provider for Entra ID authentication.
109
-
110
- Uses LiteLLM's built-in helper which leverages DefaultAzureCredential:
111
- - Azure CLI credentials (az login)
112
- - Managed Identity
113
- - Environment variables (AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, ...)
114
- - Visual Studio Code credentials
115
- """
116
- try:
117
- from litellm.secret_managers.get_azure_ad_token_provider import (
118
- get_azure_ad_token_provider,
119
- )
120
-
121
- return get_azure_ad_token_provider()
122
- except ImportError:
123
- # azure-identity not installed
124
- return None
125
- except Exception:
126
- # Credential not available
127
- return None
128
-
129
128
  @property
130
129
  def system_prompt(self) -> str:
131
130
  """Get the system prompt used for LLM assertions."""
@@ -1561,7 +1561,7 @@ wheels = [
1561
1561
 
1562
1562
  [[package]]
1563
1563
  name = "pytest-llm-assert"
1564
- version = "0.2.0"
1564
+ version = "0.2.1"
1565
1565
  source = { editable = "." }
1566
1566
  dependencies = [
1567
1567
  { name = "azure-identity" },