1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-06-16 17:40:57 +03:00

Use relative imports when importing other modules in the same directory

We were using absolute imports under the assumption that the /scripts
directory is in the path. This worked in normal use because every one of our
Python scripts either were in the /scripts directory, or added the /scripts
directory to the module search path in order to reference mbedtls_dev.
However, this broke things like
```
python3 -m unittest scripts/mbedtls_dev/psa_storage.py
```

Fix this by using relative imports.

Relative imports are only supposed to be used inside a package (Python
doesn't complain, but Pylint does). So make /scripts/mbedtls_dev a proper
package by creating __init__.py.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2022-09-16 22:35:18 +02:00
parent ca980c037f
commit 239765ad3e
5 changed files with 8 additions and 5 deletions

View File

@ -29,8 +29,8 @@ import re
from abc import ABCMeta, abstractmethod
from typing import Callable, Dict, Iterable, Iterator, List, Type, TypeVar
from mbedtls_dev import build_tree
from mbedtls_dev import test_case
from . import build_tree
from . import test_case
T = TypeVar('T') #pylint: disable=invalid-name