Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 1 | # Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved. |
| 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. |
| 16 | # Description: |
| 17 | # Unit tests for model_reader. |
| 18 | import pytest |
Louis Verhaard | 0b8268a | 2020-08-05 16:11:29 +0200 | [diff] [blame] | 19 | |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 20 | from ethosu.vela import model_reader |
| 21 | from ethosu.vela.errors import InputFileError |
| 22 | |
| 23 | |
| 24 | def test_read_model_incorrect_extension(tmpdir): |
| 25 | # Tests read_model with a file name that does not end with .tflite |
| 26 | with pytest.raises(InputFileError): |
| 27 | model_reader.read_model("no_tflite_file.txt", model_reader.ModelReaderOptions()) |
| 28 | |
| 29 | |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 30 | def test_read_model_file_not_found(tmpdir): |
| 31 | # Tests read_model with a .tflite file that does not exist |
Tim Hall | c8310b1 | 2020-06-17 14:53:11 +0100 | [diff] [blame] | 32 | with pytest.raises(FileNotFoundError): |
Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame] | 33 | model_reader.read_model("non_existing.tflite", model_reader.ModelReaderOptions()) |