⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gr_unittest.py

📁 gnuradio软件无线电源程序.现在的手机多基于软件无线电
💻 PY
字号:
#!/usr/bin/env python## Copyright 2004 Free Software Foundation, Inc.# # This file is part of GNU Radio# # GNU Radio is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.# # GNU Radio is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.# # You should have received a copy of the GNU General Public License# along with GNU Radio; see the file COPYING.  If not, write to# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,# Boston, MA 02111-1307, USA.# import unittestclass TestCase(unittest.TestCase):    """A subclass of unittest.TestCase that adds additional assertions    Adds new methods assertComplexAlmostEqual,    assertComplexTuplesAlmostEqual and assertFloatTuplesAlmostEqual    """    def assertComplexAlmostEqual (self, first, second, places=7, msg=None):        """Fail if the two complex objects are unequal as determined by their           difference rounded to the given number of decimal places           (default 7) and comparing to zero.           Note that decimal places (from zero) is usually not the same           as significant digits (measured from the most signficant digit).        """        if round(second.real-first.real, places) != 0:            raise self.failureException, \                  (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))        if round(second.imag-first.imag, places) != 0:            raise self.failureException, \                  (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))            def assertComplexTuplesAlmostEqual (self, a, b, places=7, msg=None):        self.assertEqual (len(a), len(b))        for i in xrange (len(a)):            self.assertComplexAlmostEqual (a[i], b[i], places, msg)    def assertFloatTuplesAlmostEqual (self, a, b, places=7, msg=None):        self.assertEqual (len(a), len(b))        for i in xrange (len(a)):            self.assertAlmostEqual (a[i], b[i], places, msg)TestResult = unittest.TestResultTestSuite = unittest.TestSuiteFunctionTestCase = unittest.FunctionTestCaseTestLoader = unittest.TestLoaderTextTestRunner = unittest.TextTestRunnerTestProgram = unittest.TestProgrammain = TestProgram############################################################################### Executing this module from the command line##############################################################################if __name__ == "__main__":    main(module=None)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -