test_api_tutorial.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #
  2. # Metrix++, Copyright 2009-2013, Metrix++ Project
  3. # Link: http://metrixplusplus.sourceforge.net
  4. #
  5. # This file is a part of Metrix++ Tool.
  6. #
  7. # Metrix++ is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, version 3 of the License.
  10. #
  11. # Metrix++ is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Metrix++. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. import unittest
  20. import os
  21. import tests.common
  22. class Test(tests.common.TestCase):
  23. def test_metric_plugin_api(self):
  24. #
  25. # WARNING:
  26. # files generated by this test are used by project documents page
  27. # so, if the test is changed, html docs should be updated accordingly
  28. #
  29. METRIXPLUSPLUS_PATH = None
  30. if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
  31. METRIXPLUSPLUS_PATH = os.environ['METRIXPLUSPLUS_PATH']
  32. for step in range(8):
  33. opts = ['--log-level=INFO']
  34. if step > 1:
  35. opts.append('--myext.magic.numbers')
  36. os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
  37. 'test_api_tutorial', 'ext', 'step' + str(step))
  38. runner = tests.common.ToolRunner('collect',
  39. opts,
  40. prefix='step' + str(step),
  41. check_stderr=[(0, -1)])
  42. self.assertExec(runner.run())
  43. if step < 4:
  44. continue
  45. runner = tests.common.ToolRunner('view',
  46. ['--log-level=INFO'],
  47. prefix='step' + str(step),
  48. check_stderr=[(0, -1)])
  49. self.assertExec(runner.run())
  50. if METRIXPLUSPLUS_PATH != None:
  51. os.environ['METRIXPLUSPLUS_PATH'] = METRIXPLUSPLUS_PATH
  52. if __name__ == '__main__':
  53. unittest.main()