[ovs-dev] [PATCH v1] tests: fix python2 module not find error
Ilya Maximets
i.maximets at ovn.org
Fri Jul 16 18:51:08 UTC 2021
On 7/16/21 8:15 PM, kumar Amber wrote:
> This fixes the flake8 error on pyhton version older than 3.6
> as ModuleNotFoundError in not available before 3.6 and that is now
> replaced to ImportError which is present in earlier versions.
>
> ../../tests/mfex_fuzzy.py:5:8: F821 undefined name 'ModuleNotFoundError'
> 2653Makefile:5826: recipe for target 'flake8-check' failed
>
> Fixes: 50be6715c0 ("test/sytem-dpdk: Add unit test for mfex autovalidator")
> Signed-off-by: kumar Amber <kumar.amber at intel.com>
> ---
> tests/mfex_fuzzy.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/mfex_fuzzy.py b/tests/mfex_fuzzy.py
> index 5b056bb48..fd257ffb6 100755
> --- a/tests/mfex_fuzzy.py
> +++ b/tests/mfex_fuzzy.py
> @@ -2,7 +2,7 @@
> try:
> from scapy.all import RandMAC, RandIP, PcapWriter, RandIP6, RandShort, fuzz
> from scapy.all import IPv6, Dot1Q, IP, Ether, UDP, TCP
> -except ModuleNotFoundError as err:
> +except ImportError as err:
> print(err + ": Scapy")
> import sys
>
>
I can confirm that this fixes the flake8 issue.
But I'm not sure how that is supposed to work at all.
Here is what I get in a plain python console:
Python 3.6.8 (default, Mar 18 2021, 08:58:41)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
... from scapy.all import RandMAC
... except ImportError as err:
... print(err + ": Scapy")
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ModuleNotFoundError: No module named 'scapy'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
TypeError: unsupported operand type(s) for +: 'ModuleNotFoundError' and 'str'
Best regards, Ilya Maximets.
More information about the dev
mailing list