2017-10-08 19:02:38 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
"""test the raising of errors with the error module
|
|
|
|
|
2023-08-14 23:03:36 +00:00
|
|
|
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
2017-10-08 19:02:38 +00:00
|
|
|
:organization: `python-escpos <https://github.com/python-escpos>`_
|
|
|
|
:copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_
|
|
|
|
:license: MIT
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2017-10-08 19:27:23 +00:00
|
|
|
import pytest
|
2023-08-14 23:03:36 +00:00
|
|
|
|
2017-10-08 19:02:38 +00:00
|
|
|
import escpos
|
2017-10-08 19:27:23 +00:00
|
|
|
import escpos.exceptions
|
2017-10-08 19:02:38 +00:00
|
|
|
|
|
|
|
|
2017-10-08 19:27:23 +00:00
|
|
|
def test_raise_error_wrongly():
|
|
|
|
"""raise error the wrong way
|
2017-10-08 19:02:38 +00:00
|
|
|
|
|
|
|
should reproduce https://github.com/python-escpos/python-escpos/issues/257
|
|
|
|
"""
|
2017-10-08 19:27:23 +00:00
|
|
|
with pytest.raises(AttributeError):
|
|
|
|
raise escpos.Error("This should raise an AttributeError.")
|
|
|
|
|
|
|
|
|
2023-12-16 22:09:20 +00:00
|
|
|
def tests_raise_error() -> None:
|
2017-10-08 19:27:23 +00:00
|
|
|
"""raise error the right way"""
|
|
|
|
with pytest.raises(escpos.exceptions.Error):
|
|
|
|
raise escpos.exceptions.Error("This should raise an error.")
|