Skip to content

Commit e0b95dc

Browse files
chore(internal): codegen related update
1 parent 3e006df commit e0b95dc

3 files changed

Lines changed: 6 additions & 49 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ dev-dependencies = [
5656
"dirty-equals>=0.6.0",
5757
"importlib-metadata>=6.7.0",
5858
"rich>=13.7.1",
59-
"nest_asyncio==1.6.0",
6059
"pytest-xdist>=3.6.1",
6160
]
6261

requirements-dev.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ multidict==6.4.4
7575
mypy==1.14.1
7676
mypy-extensions==1.0.0
7777
# via mypy
78-
nest-asyncio==1.6.0
7978
nodeenv==1.8.0
8079
# via pyright
8180
nox==2023.4.22

tests/test_client.py

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
import os
77
import sys
88
import json
9-
import time
109
import asyncio
1110
import inspect
12-
import subprocess
1311
import tracemalloc
1412
from typing import Any, Union, cast
15-
from textwrap import dedent
1613
from unittest import mock
1714
from typing_extensions import Literal
1815

@@ -23,14 +20,17 @@
2320

2421
from telnyx import Telnyx, AsyncTelnyx, APIResponseValidationError
2522
from telnyx._types import Omit
23+
from telnyx._utils import asyncify
2624
from telnyx._models import BaseModel, FinalRequestOptions
2725
from telnyx._exceptions import TelnyxError, APIStatusError, APITimeoutError, APIResponseValidationError
2826
from telnyx._base_client import (
2927
DEFAULT_TIMEOUT,
3028
HTTPX_DEFAULT_TIMEOUT,
3129
BaseClient,
30+
OtherPlatform,
3231
DefaultHttpxClient,
3332
DefaultAsyncHttpxClient,
33+
get_platform,
3434
make_request_options,
3535
)
3636

@@ -1623,50 +1623,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16231623

16241624
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
16251625

1626-
def test_get_platform(self) -> None:
1627-
# A previous implementation of asyncify could leave threads unterminated when
1628-
# used with nest_asyncio.
1629-
#
1630-
# Since nest_asyncio.apply() is global and cannot be un-applied, this
1631-
# test is run in a separate process to avoid affecting other tests.
1632-
test_code = dedent("""
1633-
import asyncio
1634-
import nest_asyncio
1635-
import threading
1636-
1637-
from telnyx._utils import asyncify
1638-
from telnyx._base_client import get_platform
1639-
1640-
async def test_main() -> None:
1641-
result = await asyncify(get_platform)()
1642-
print(result)
1643-
for thread in threading.enumerate():
1644-
print(thread.name)
1645-
1646-
nest_asyncio.apply()
1647-
asyncio.run(test_main())
1648-
""")
1649-
with subprocess.Popen(
1650-
[sys.executable, "-c", test_code],
1651-
text=True,
1652-
) as process:
1653-
timeout = 10 # seconds
1654-
1655-
start_time = time.monotonic()
1656-
while True:
1657-
return_code = process.poll()
1658-
if return_code is not None:
1659-
if return_code != 0:
1660-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1661-
1662-
# success
1663-
break
1664-
1665-
if time.monotonic() - start_time > timeout:
1666-
process.kill()
1667-
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1668-
1669-
time.sleep(0.1)
1626+
async def test_get_platform(self) -> None:
1627+
platform = await asyncify(get_platform)()
1628+
assert isinstance(platform, (str, OtherPlatform))
16701629

16711630
async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None:
16721631
# Test that the proxy environment variables are set correctly

0 commit comments

Comments
 (0)