diff --git a/tests/README.md b/tests/README.md index 6ba72e4aced2ae06f1ae8e004492acceeb07a9ce..ce662128709cba2f08a190a3a4f9cfc8d0e0f07d 100644 --- a/tests/README.md +++ b/tests/README.md @@ -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:` diff --git a/tests/conftest.py b/tests/conftest.py index da1c26e54a3735c670cb498af472529f400d53c2..a4678c7d28df778dbb0b4bb464b1c8589a1864e6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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