test_internal_utils.py 556 B

1234567891011121314151617
  1. import pytest
  2. from torchvision._utils import sequence_to_str
  3. @pytest.mark.parametrize(
  4. ("seq", "separate_last", "expected"),
  5. [
  6. ([], "", ""),
  7. (["foo"], "", "'foo'"),
  8. (["foo", "bar"], "", "'foo', 'bar'"),
  9. (["foo", "bar"], "and ", "'foo' and 'bar'"),
  10. (["foo", "bar", "baz"], "", "'foo', 'bar', 'baz'"),
  11. (["foo", "bar", "baz"], "and ", "'foo', 'bar', and 'baz'"),
  12. ],
  13. )
  14. def test_sequence_to_str(seq, separate_last, expected):
  15. assert sequence_to_str(seq, separate_last=separate_last) == expected