-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright DB Netz AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
sys.path.insert(1, str(Path(__file__).parent.parent.parent.parent)) | ||
|
||
from raillabel._util._warning import _warning, _WarningsLogger | ||
|
||
|
||
def test_issue_warning(): | ||
with _WarningsLogger() as logger: | ||
_warning("lorem ipsum") | ||
|
||
assert logger.warnings == [ | ||
"lorem ipsum" | ||
] | ||
|
||
def test_handover_exception(): | ||
with pytest.raises(RuntimeError) as error: | ||
with _WarningsLogger() as logger: | ||
raise RuntimeError("weewoo something went wrong") | ||
|
||
def test_clear_warnings(): | ||
with _WarningsLogger() as logger1: | ||
_warning("lorem ipsum") | ||
|
||
with _WarningsLogger() as logger2: | ||
pass | ||
|
||
assert len(logger2.warnings) == 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
os.system("clear") | ||
pytest.main([__file__, "--disable-pytest-warnings", "--cache-clear", "-v"]) |