source: tests/python/unittest_examples.py @ 031b1f9

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 031b1f9 was 4aad0dc, checked in by Paul Brossier <piem@piem.org>, 16 years ago

added simple unittest tests as examples

  • Property mode set to 100644
File size: 873 bytes
Line 
1import unittest
2
3# this file is just to illustrates and test some of the unittest module
4# functionalities.
5
6class raise_test_case(unittest.TestCase):
7  def test_assertEqual(self):
8    """ check assertEqual returns AssertionError """
9    try:
10      self.assertEqual(0.,1.)
11    except AssertionError:
12      pass
13    else:
14      fail('expected an AssertionError exception')
15
16  def test_assertAlmostEqual(self):
17    """ check assertAlmostEqual returns AssertionError """
18    try:
19      self.assertAlmostEqual(0.,1.)
20    except AssertionError:
21      pass
22    else:
23      fail('expected an AssertionError exception')
24
25  def test_assertRaises(self):
26    """ check assertRaises works as expected """
27    self.assertRaises(AssertionError, self.assertEqual, 0.,1.)
28    self.assertRaises(AssertionError, self.assertAlmostEqual, 0.,1.,1)
29
30if __name__ == '__main__':
31  unittest.main()
Note: See TracBrowser for help on using the repository browser.