1
0
forked from M-Labs/artiq
artiq/artiq/test/lda.py

35 lines
945 B
Python
Raw Normal View History

2015-02-19 02:33:25 +08:00
import unittest
import os
2015-02-19 02:34:00 +08:00
2015-02-19 02:33:25 +08:00
from artiq.devices.lda.driver import Lda, Ldasim
from artiq.language.units import dB
lda_serial = os.getenv("ARTIQ_LDA_SERIAL")
2015-02-19 02:33:25 +08:00
class GenericLdaTest:
def test_attenuation(self):
step = self.cont.get_att_step_size().amount
max = self.cont.get_att_max().amount
test_vector = [i*step*dB for i in range(0, int(max*int(1/step)+1))]
for i in test_vector:
with self.subTest(i=i):
self.cont.set_attenuation(i)
self.assertEqual(i, self.cont.get_attenuation())
@unittest.skipUnless(lda_serial, "no hardware")
2015-02-19 02:33:25 +08:00
class TestLda(GenericLdaTest, unittest.TestCase):
def setUp(self):
product = os.getenv("ARTIQ_LDA_PRODUCT")
self.cont = Lda(serial=lda_serial, product=product)
2015-02-19 02:33:25 +08:00
class TestLdaSim(GenericLdaTest, unittest.TestCase):
def setUp(self):
self.cont = Ldasim()
if __name__ == "__main__":
unittest.main()