Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pydantic = ">=1.9.0,<3.0"
pydantic-core = ">=2.14.6"
cachetools = ">=4.2.2"
pyjwt = "~=2.8.0"
sniffio = ">=1.3.0"


[tool.poetry.group.test.dependencies]
Expand Down
15 changes: 15 additions & 0 deletions tests/installation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Installed-package smoke tests

Run these checks in a fresh environment after building and installing the wheel,
without installing test or development extras. This catches runtime dependencies
that an existing development environment can accidentally provide.

```sh
python -m pip wheel . --no-deps --wheel-dir dist
python -m venv /tmp/zhipuai-install-test
/tmp/zhipuai-install-test/bin/python -m pip install dist/zhipuai-*.whl
/tmp/zhipuai-install-test/bin/python -I tests/installation/test_installed_sdk.py -v
```

The isolated interpreter imports the installed package rather than the source
checkout. The tests create no API requests and require only runtime dependencies.
27 changes: 27 additions & 0 deletions tests/installation/test_installed_sdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Run with ``python -I`` after installing a wheel in a clean environment."""

import asyncio
import unittest


class InstalledSDKTests(unittest.TestCase):
def test_public_sdk_import(self):
from zhipuai import ZhipuAI

with ZhipuAI(api_key='test-key') as client:
self.assertFalse(client.is_closed())
self.assertTrue(client.is_closed())

def test_async_library_detection(self):
from zhipuai.core._utils import get_async_library

self.assertEqual(get_async_library(), 'false')

async def detect():
return get_async_library()

self.assertEqual(asyncio.run(detect()), 'asyncio')


if __name__ == '__main__':
unittest.main()
Loading