def setUpFor(self, mode, demod_class=None, state=None, skip_if_unavailable=False): # pylint: disable=attribute-defined-outside-init if state is None: state = {} mode_def = lookup_mode(mode, include_unavailable=True) if mode_def and not mode_def.available and skip_if_unavailable: raise unittest.SkipTest( 'mode {!r} marked unavailable'.format(mode)) if mode_def is not None and demod_class is None: demod_class = mode_def.demod_class if demod_class is None: if mode_def is None: raise Exception('Mode {!r} not registered'.format(mode)) else: raise Exception( 'Demodulator not registered for mode {!r}'.format(mode)) # Wire up top block. We don't actually want to inspect the signal processing; we just want to see if GR has a complaint about the flow graph connectivity. self.__top = gr.top_block() self.__adapter = DemodulatorAdapter(mode=mode, demod_class=demod_class, input_rate=100000, output_rate=22050, quiet=True) self.demodulator = self.__adapter.get_demodulator() self.__top.connect(blocks.vector_source_c([]), (self.__adapter, 0), blocks.null_sink(gr.sizeof_float)) self.__top.connect((self.__adapter, 1), blocks.null_sink(gr.sizeof_float)) DemodulatorTestCase.setUp(self) # neither super nor self call
def setUpFor(self, mode, demod_class=None, state=None, skip_if_unavailable=False): # pylint: disable=attribute-defined-outside-init if state is None: state = {} mode_def = lookup_mode(mode, include_unavailable=True) if mode_def and not mode_def.available and skip_if_unavailable: raise unittest.SkipTest('mode {!r} marked unavailable'.format(mode)) if mode_def is not None and demod_class is None: demod_class = mode_def.demod_class if demod_class is None: if mode_def is None: raise Exception('Mode {!r} not registered'.format(mode)) else: raise Exception('Demodulator not registered for mode {!r}'.format(mode)) # Wire up top block. We don't actually want to inspect the signal processing; we just want to see if GR has a complaint about the flow graph connectivity. self.__top = gr.top_block() self.__adapter = DemodulatorAdapter( mode=mode, demod_class=demod_class, input_rate=100000, output_rate=22050, quiet=True) self.demodulator = self.__adapter.get_demodulator() self.__top.connect( blocks.vector_source_c([]), (self.__adapter, 0), blocks.null_sink(gr.sizeof_float)) self.__top.connect( (self.__adapter, 1), blocks.null_sink(gr.sizeof_float)) DemodulatorTestCase.setUp(self) # neither super nor self call
class DemodulatorTestCase(unittest.TestCase): """ Set up an environment for testing a demodulator and do some fundamental tests. """ def setUp(self): # pylint: disable=unidiomatic-typecheck self.__noop = type(self) is DemodulatorTestCase if not hasattr(self, 'demodulator') and not self.__noop: raise Exception('No demodulator specified for DemodulatorTestCase') def setUpFor(self, mode, demod_class=None, state=None, skip_if_unavailable=False): # pylint: disable=attribute-defined-outside-init if state is None: state = {} mode_def = lookup_mode(mode, include_unavailable=True) if mode_def and not mode_def.available and skip_if_unavailable: raise unittest.SkipTest( 'mode {!r} marked unavailable'.format(mode)) if mode_def is not None and demod_class is None: demod_class = mode_def.demod_class if demod_class is None: if mode_def is None: raise Exception('Mode {!r} not registered'.format(mode)) else: raise Exception( 'Demodulator not registered for mode {!r}'.format(mode)) # Wire up top block. We don't actually want to inspect the signal processing; we just want to see if GR has a complaint about the flow graph connectivity. self.__top = gr.top_block() self.__adapter = DemodulatorAdapter(mode=mode, demod_class=demod_class, input_rate=100000, output_rate=22050, quiet=True) self.demodulator = self.__adapter.get_demodulator() self.__top.connect(blocks.vector_source_c([]), (self.__adapter, 0), blocks.null_sink(gr.sizeof_float)) self.__top.connect((self.__adapter, 1), blocks.null_sink(gr.sizeof_float)) DemodulatorTestCase.setUp(self) # neither super nor self call def tearDown(self): if self.__noop: return self.__top.stop() self.__top.wait() def test_implements(self): if self.__noop: return verifyObject(IDemodulator, self.demodulator) def test_state(self): if self.__noop: return state_smoke_test(self.demodulator)
class DemodulatorTestCase(unittest.TestCase): """ Set up an environment for testing a demodulator and do some fundamental tests. """ def setUp(self): # pylint: disable=unidiomatic-typecheck self.__noop = type(self) is DemodulatorTestCase if not hasattr(self, 'demodulator') and not self.__noop: raise Exception('No demodulator specified for DemodulatorTestCase') def setUpFor(self, mode, demod_class=None, state=None, skip_if_unavailable=False): # pylint: disable=attribute-defined-outside-init if state is None: state = {} mode_def = lookup_mode(mode, include_unavailable=True) if mode_def and not mode_def.available and skip_if_unavailable: raise unittest.SkipTest('mode {!r} marked unavailable'.format(mode)) if mode_def is not None and demod_class is None: demod_class = mode_def.demod_class if demod_class is None: if mode_def is None: raise Exception('Mode {!r} not registered'.format(mode)) else: raise Exception('Demodulator not registered for mode {!r}'.format(mode)) # Wire up top block. We don't actually want to inspect the signal processing; we just want to see if GR has a complaint about the flow graph connectivity. self.__top = gr.top_block() self.__adapter = DemodulatorAdapter( mode=mode, demod_class=demod_class, input_rate=100000, output_rate=22050, quiet=True) self.demodulator = self.__adapter.get_demodulator() self.__top.connect( blocks.vector_source_c([]), (self.__adapter, 0), blocks.null_sink(gr.sizeof_float)) self.__top.connect( (self.__adapter, 1), blocks.null_sink(gr.sizeof_float)) DemodulatorTestCase.setUp(self) # neither super nor self call def tearDown(self): if self.__noop: return self.__top.stop() self.__top.wait() def test_implements(self): if self.__noop: return verifyObject(IDemodulator, self.demodulator) def test_state(self): if self.__noop: return state_smoke_test(self.demodulator)