Rickard Bolin | bc6ee58 | 2022-11-04 08:24:29 +0000 | [diff] [blame^] | 1 | # SPDX-FileCopyrightText: Copyright 2020 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 2 | # |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the License); you may |
| 6 | # not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Rickard Bolin | bc6ee58 | 2022-11-04 08:24:29 +0000 | [diff] [blame^] | 16 | # |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 17 | # Description: |
| 18 | # Unit tests for model_reader. |
| 19 | import pytest |
Louis Verhaard | 0b8268a | 2020-08-05 16:11:29 +0200 | [diff] [blame] | 20 | |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 21 | from ethosu.vela import model_reader |
| 22 | from ethosu.vela.errors import InputFileError |
| 23 | |
| 24 | |
| 25 | def test_read_model_incorrect_extension(tmpdir): |
| 26 | # Tests read_model with a file name that does not end with .tflite |
| 27 | with pytest.raises(InputFileError): |
| 28 | model_reader.read_model("no_tflite_file.txt", model_reader.ModelReaderOptions()) |
| 29 | |
| 30 | |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 31 | def test_read_model_file_not_found(tmpdir): |
| 32 | # Tests read_model with a .tflite file that does not exist |
Tim Hall | c8310b1 | 2020-06-17 14:53:11 +0100 | [diff] [blame] | 33 | with pytest.raises(FileNotFoundError): |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 34 | model_reader.read_model("non_existing.tflite", model_reader.ModelReaderOptions()) |