Skip to content

Commit

Permalink
Add cache + container tests, use 3.10 for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Mar 12, 2023
1 parent 7d1da5a commit 620073c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.10"
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
Expand Down
8 changes: 8 additions & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,11 @@ def main(value: tyro.conf.Suppress[int]) -> int:

with pytest.raises(tyro.UnsupportedTypeAnnotationError):
tyro.cli(main, args=["--help"])


def test_ambiguous_sequence() -> None:
def main(value: list) -> None:
return None

with pytest.raises(tyro.UnsupportedTypeAnnotationError):
tyro.cli(main, args=["--help"])
31 changes: 31 additions & 0 deletions tests/test_unsafe_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from tyro import _unsafe_cache


def test_unsafe_cache():
x = 0

@_unsafe_cache.unsafe_cache(maxsize=2)
def f(dummy: int):
nonlocal x
x += 1

f(0)
f(0)
f(0)
assert x == 1
f(1)
f(1)
f(1)
assert x == 2
f(0)
f(0)
f(0)
assert x == 2
f(2)
f(2)
f(2)
assert x == 3
f(0)
f(0)
f(0)
assert x == 4

0 comments on commit 620073c

Please sign in to comment.