(to_cpu)
| 749 | |
| 750 | @pytest.mark.parametrize("to_cpu", [False, True]) |
| 751 | def test_model_unload(to_cpu): |
| 752 | batch = [["آ", "ت", "ز", "م", "و", "ن"]] |
| 753 | translator = _get_transliterator() |
| 754 | translator.unload_model(to_cpu=to_cpu) |
| 755 | if not to_cpu: |
| 756 | assert not translator.model_is_loaded |
| 757 | with pytest.raises(RuntimeError, match="unloaded"): |
| 758 | translator.translate_batch(batch) |
| 759 | else: |
| 760 | assert translator.model_is_loaded |
| 761 | translator.load_model() |
| 762 | assert translator.model_is_loaded |
| 763 | output = translator.translate_batch(batch) |
| 764 | assert len(output) == 1 |
| 765 | assert output[0].hypotheses[0] == ["a", "t", "z", "m", "o", "n"] |
| 766 | |
| 767 | |
| 768 | def test_model_unload_while_async_translation(): |
nothing calls this directly
no test coverage detected