mirror of
https://github.com/python-escpos/python-escpos
synced 2025-08-24 09:03:34 +00:00
558 improve capabilities handling (#562)
* add handling for missing capabilities file * improve documentation * Update doc/user/installation.rst
This commit is contained in:
29
test/test_load_module_missing_capability.py
Normal file
29
test/test_load_module_missing_capability.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python
|
||||
"""basic test case that simulates an empty capability file
|
||||
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_instantiation():
|
||||
"""test the instantiation of a escpos-printer class"""
|
||||
# inject an environment variable that points to an empty capabilities file
|
||||
os.environ["ESCPOS_CAPABILITIES_FILE"] = tempfile.NamedTemporaryFile().name
|
||||
|
||||
import escpos.printer as printer
|
||||
from escpos.exceptions import BarcodeTypeError
|
||||
|
||||
# remove again the variable (so that no other tests are affected)
|
||||
os.environ.pop("ESCPOS_CAPABILITIES_FILE")
|
||||
|
||||
instance = printer.Dummy()
|
||||
with pytest.raises(BarcodeTypeError):
|
||||
instance.barcode("bc", "code")
|
Reference in New Issue
Block a user