def test_crash_may_not_influence_following_tests(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") _ = Spectrometer.from_serial_number(backendlified_serial) raise Exception("crash on purpose")
def test_read_spectrum(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") spec = Spectrometer.from_serial_number(backendlified_serial) arr = spec.spectrum() assert arr.shape == (2, spec.pixels)
def test_read_serial_number(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") spec = Spectrometer.from_serial_number(backendlified_serial) serial = spec.serial_number assert len(serial) > 0
def test_max_intensity(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") spec = Spectrometer.from_serial_number(backendlified_serial) value = spec.max_intensity assert isinstance(value, float) assert 0 < value < 1e8
def test_integration_time_limits(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") spec = Spectrometer.from_serial_number(backendlified_serial) low, high = spec.integration_time_micros_limits assert isinstance(low, int) assert isinstance(high, int) assert 0 < low < high < 2**64
def test_trigger_mode(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") exc = Spectrometer._backend.SeaBreezeError spec = Spectrometer.from_serial_number(backendlified_serial) spec.trigger_mode(0x00) # <- normal mode with pytest.raises(exc): spec.trigger_mode(0xF0) # <- should be unsupported for all specs # test again to see if the bus is locked spec.trigger_mode(0x00) # <- normal mode
def test_correct_dark_pixels(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") # noinspection PyProtectedMember SeaBreezeError = Spectrometer._backend.SeaBreezeError spec = Spectrometer.from_serial_number(backendlified_serial) try: arr = spec.intensities(correct_dark_counts=True) except SeaBreezeError: pytest.skip("does not support dark counts") else: assert arr.size == spec.pixels
def test_integration_time(backendlified_serial): devices = list(list_devices()) if len(devices) == 0: pytest.skip("no supported device connected") exc = Spectrometer._backend.SeaBreezeError spec = Spectrometer.from_serial_number(backendlified_serial) with pytest.raises(exc): # fail because too low spec.integration_time_micros(0) with pytest.raises(exc): # fail because too large spec.integration_time_micros(2**62) with pytest.raises(exc): # fail because too large long overflow spec.integration_time_micros(2**64) spec.integration_time_micros(10000)
def test_cant_find_serial(): exc = Spectrometer._backend.SeaBreezeError with pytest.raises(exc): Spectrometer.from_serial_number("i-do-not-exist")