mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-04 00:18:36 +00:00
fix(config): install timezone data on all platforms
This commit is contained in:
parent
6a1a45d07a
commit
dda9b61b1e
@ -51,7 +51,7 @@ dependencies = [
|
||||
"filelock>=3.25.2",
|
||||
"watchfiles>=1.1.1,<2.0.0",
|
||||
"packaging>=24.0",
|
||||
"tzdata>=2025.2; sys_platform == 'win32'",
|
||||
"tzdata>=2025.2",
|
||||
"defusedxml>=0.7.1,<1.0.0",
|
||||
"pypdf>=5.0.0,<6.0.0",
|
||||
"python-docx>=1.1.0,<2.0.0",
|
||||
|
||||
@ -2558,7 +2558,7 @@ def test_optional_dependency_metadata_for_enable():
|
||||
):
|
||||
assert not any(dep.startswith(dep_name) for dep in required)
|
||||
for dependency in (
|
||||
"tzdata>=2025.2; sys_platform == 'win32'",
|
||||
"tzdata>=2025.2",
|
||||
"defusedxml>=0.7.1,<1.0.0",
|
||||
"pypdf>=5.0.0,<6.0.0",
|
||||
"python-docx>=1.1.0,<2.0.0",
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
@ -42,6 +46,32 @@ def test_agent_timezone_rejects_unknown_iana_name() -> None:
|
||||
Config.model_validate({"agents": {"defaults": {"timezone": "Not/AZone"}}})
|
||||
|
||||
|
||||
def test_agent_timezones_use_packaged_data_without_system_database() -> None:
|
||||
script = textwrap.dedent(
|
||||
"""\
|
||||
from zoneinfo import TZPATH
|
||||
|
||||
from nanobot.config.schema import Config
|
||||
|
||||
assert not TZPATH
|
||||
for name in ("UTC", "Asia/Shanghai"):
|
||||
config = Config.model_validate({"agents": {"defaults": {"timezone": name}}})
|
||||
serialized = config.model_dump(mode="json", by_alias=True)
|
||||
restored = Config.model_validate(serialized)
|
||||
assert restored.agents.defaults.timezone == name
|
||||
"""
|
||||
)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", script],
|
||||
env=os.environ | {"PYTHONTZPATH": ""},
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
|
||||
|
||||
def test_provider_api_type_accepts_exact_values_only() -> None:
|
||||
config = Config.model_validate({
|
||||
"providers": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user