5 This script contains basic "unit" tests, implemented for and executed with pytest.
8 pytest (pip install pytest)
11 <project root>$ pytest [-m {basic}]
13 :copyright: (c) 2020 by Manuel Rom <roma@synpro.solutions>
14 :license: GPL v2 or any later version
15 :bugreports: http://grml.org/bugs/
23 grml2usb = importlib.import_module("grml2usb", ".")
26 @pytest.mark.check_for_usbdevice
27 def test_extract_device_name():
28 """Assert, that 'extract_device_name' returns a device name for a given path"""
29 assert grml2usb.extract_device_name("/dev/sda") == "sda"
30 assert grml2usb.extract_device_name("/dev/sdb") == "sdb"
31 assert grml2usb.extract_device_name("/dev/sdb4") == "sdb"
34 @pytest.mark.check_for_usbdevice
35 def test_extract_device_name_invalid():
36 """Assert, that 'extract_device_name' raises an Error, when given an incorrect string"""
37 with pytest.raises(AttributeError):
38 assert grml2usb.extract_device_name("/dev")
39 with pytest.raises(AttributeError):
40 assert grml2usb.extract_device_name("foobar")