test_api_tutorial.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_basic(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. os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
  33. 'test_api_tutorial', 'ext', 'step1')
  34. runner = tests.common.ToolRunner('collect',
  35. ['--log-level=INFO'],
  36. prefix='step1',
  37. check_stderr=[(0, -1)])
  38. self.assertExec(runner.run())
  39. os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
  40. 'test_api_tutorial', 'ext', 'step2')
  41. runner = tests.common.ToolRunner('collect',
  42. ['--log-level=INFO',
  43. '--myext.magic.numbers'],
  44. prefix='step2',
  45. check_stderr=[(0, -1)])
  46. self.assertExec(runner.run())
  47. os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
  48. 'test_api_tutorial', 'ext', 'step3')
  49. runner = tests.common.ToolRunner('collect',
  50. ['--log-level=INFO',
  51. '--myext.magic.numbers'],
  52. prefix='step3',
  53. check_stderr=[(0, -1)])
  54. self.assertExec(runner.run())
  55. os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
  56. 'test_api_tutorial', 'ext', 'step4')
  57. runner = tests.common.ToolRunner('collect',
  58. ['--log-level=INFO',
  59. '--myext.magic.numbers'],
  60. prefix='step4',
  61. check_stderr=[(0, -1)])
  62. self.assertExec(runner.run())
  63. runner = tests.common.ToolRunner('view',
  64. ['--log-level=INFO'],
  65. prefix='step4',
  66. check_stderr=[(0, -1)])
  67. self.assertExec(runner.run())
  68. os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
  69. 'test_api_tutorial', 'ext', 'step5')
  70. runner = tests.common.ToolRunner('collect',
  71. ['--log-level=INFO',
  72. '--myext.magic.numbers'],
  73. prefix='step5',
  74. check_stderr=[(0, -1)])
  75. self.assertExec(runner.run())
  76. runner = tests.common.ToolRunner('view',
  77. ['--log-level=INFO'],
  78. prefix='step5',
  79. check_stderr=[(0, -1)])
  80. self.assertExec(runner.run())
  81. if METRIXPLUSPLUS_PATH != None:
  82. os.environ['METRIXPLUSPLUS_PATH'] = METRIXPLUSPLUS_PATH
  83. if __name__ == '__main__':
  84. unittest.main()