Commit 3f7b714c authored by premathasara's avatar premathasara
Browse files

Replace pytest.exit with FileNotFoundError so that error is reported properly....

Replace pytest.exit with FileNotFoundError so that error is reported properly. This is because xdist incorrect intercepts a pytest.exit as a keyboard interrupt and removes the error message.
parent 394140be
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ Commonly used options like `-n auto` are added to addopts within the [pytest] se

The `-v` (or `--verbose`) option is helpful to see what is going on.

If an error occurs that lacks details or if you see a "keyboard interrupt" reported by xdist, try running pytest with `-n 0`. This may provide more accurate details for the source of the error.

Avoid using pytest.exit in the pytest test code, and instead raise an exception. This is because xdist does not capture pytest.exit properly, hiding the error message and reporting a false keyboard interrupt.

## Custom options

`Note:`
+5 −5
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ def dut_encoder_path(request) -> str:
    path = str(path.resolve())

    if not os.path.isfile(path):
        pytest.exit(f"\nDUT encoder binary {path} not found!\n!")
        raise FileNotFoundError(f"DUT encoder binary {path} not found!\n!")

    return path

@@ -296,7 +296,7 @@ def ref_encoder_path(request) -> str:
    path = str(path.resolve())

    if not os.path.isfile(path):
        pytest.exit(f"\nREF encoder binary {path} not found!\n!")
        raise FileNotFoundError(f"REF encoder binary {path} not found!\n!")

    return path

@@ -322,7 +322,7 @@ def dut_decoder_path(request) -> str:
    path = str(path.resolve())

    if not os.path.isfile(path):
        pytest.exit(f"\nDUT decoder binary {path} not found!\n!")
        raise FileNotFoundError(f"DUT decoder binary {path} not found!\n!")

    return path

@@ -430,7 +430,7 @@ def ref_decoder_path(request) -> str:
    path = str(path.resolve())

    if not os.path.isfile(path):
        pytest.exit(f"\nREF decoder binary {path} not found!\n!")
        raise FileNotFoundError(f"REF decoder binary {path} not found!\n!")

    return path

@@ -468,7 +468,7 @@ def reference_path(request) -> str:

    if request.config.option.update_ref == "0":
        if not os.path.isdir(path):
            pytest.exit(f"\nREF path {path} not found!\nPlease generate the references, first!\n!")
            raise FileNotFoundError(f"REF path {path} not found!\nPlease generate the references, first!\n!")

    return path