A bin folder, holding helpfull scripts and commands
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mkunittest 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. import os
  4. import stat
  5. name = os.path.basename(os.path.abspath('.'))
  6. gitignore = """# general stuff
  7. *~
  8. unittest/testresults/*
  9. unittest/output_data/*
  10. # eclipse stuff
  11. .settings/
  12. # Byte-compiled / optimized / DLL files
  13. __pycache__/
  14. *.py[cod]
  15. # C extensions
  16. *.so
  17. # Distribution / packaging
  18. .Python
  19. env/
  20. build/
  21. develop-eggs/
  22. dist/
  23. downloads/
  24. eggs/
  25. .eggs/
  26. lib/
  27. lib64/
  28. parts/
  29. sdist/
  30. var/
  31. *.egg-info/
  32. .installed.cfg
  33. *.egg
  34. # PyInstaller
  35. # Usually these files are written by a python script from a template
  36. # before PyInstaller builds the exe, so as to inject date/other infos into it.
  37. *.manifest
  38. *.spec
  39. # Installer logs
  40. pip-log.txt
  41. pip-delete-this-directory.txt
  42. # Unit test / coverage reports
  43. htmlcov/
  44. .tox/
  45. .coverage
  46. .coverage.*
  47. .cache
  48. nosetests.xml
  49. coverage.xml
  50. *,cover
  51. # Translations
  52. *.mo
  53. *.pot
  54. # Django stuff:
  55. *.log
  56. # Sphinx documentation
  57. docs/_build/
  58. # PyBuilder
  59. target/
  60. """
  61. unittest_py = """#!/usr/bin/env python
  62. # -*- coding: utf-8 -*-
  63. #
  64. import optparse
  65. import os
  66. import report
  67. import unittest
  68. import tests
  69. parser = optparse.OptionParser("usage: %prog [clean|run|coverage|pdf|copy|release]")
  70. parser.add_option("-e", "--execution-level", dest="execution_level", default="full", help="sets the execution level [full | short | smoke | single]")
  71. (options, args) = parser.parse_args()
  72. if report.TCEL_REVERSE_NAMED.get(tests.execution_level, report.TCEL_FULL) < report.TCEL_REVERSE_NAMED.get(options.execution_level, report.TCEL_FULL):
  73. options.execution_level = tests.execution_level
  74. unittest.run.unittest(options, args, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
  75. """
  76. config_py = """#!/usr/bin/env python
  77. # -*- coding: UTF-8 -*-
  78. import optparse
  79. import os
  80. import %s as lib
  81. release_unittest_version = 'xxx'
  82. lib_path = os.path.realpath(lib.__path__[0])
  83. additional_loggers_to_catch = []
  84. if __name__ == "__main__":
  85. parser = optparse.OptionParser("usage: %%prog [options] folder_for_document")
  86. parser.add_option("-p", "--path", dest="libpath", action="store_true", default=False, help="prints the library path")
  87. (options, args) = parser.parse_args()
  88. if options.libpath:
  89. print(lib_path)
  90. """ % name
  91. test_init_py = """#!/usr/bin/env python
  92. # -*- coding: UTF-8 -*-
  93. import %s
  94. from report import TCEL_FULL
  95. from report import TCEL_SHORT
  96. from report import TCEL_SINGLE
  97. from report import TCEL_SMOKE
  98. #from tests import test_
  99. execution_level = 'full'
  100. def testrun(tcl):
  101. #
  102. # caching.property_cache_json
  103. #
  104. tcl.testCase('description', TCEL_FULL, test_.func, *args, **kwargs)
  105. """ % name
  106. with open('.gitignore', 'w') as fh:
  107. fh.write(gitignore)
  108. os.mkdir('docs')
  109. os.symlink('../pylibs/%s' % name, 'docs/%s' % name)
  110. os.mkdir('pylibs')
  111. os.mkdir('requirements')
  112. os.mkdir('unittest')
  113. os.symlink('../pylibs/unittest/scripts/unittest.sh', 'unittest/unittest.sh')
  114. os.symlink('../pylibs/unittest/scripts/unittest.py', 'unittest/unittest.py')
  115. os.mkdir('unittest/input_data')
  116. os.mkdir('unittest/output_data')
  117. os.mkdir('unittest/src')
  118. with open('unittest/src/config.py', 'w') as fh:
  119. fh.write(config_py)
  120. with open('unittest/src/unittest.py', 'w') as fh:
  121. fh.write(unittest_py)
  122. for lib_name in [name, 'report', 'unittest', 'fstools', 'reqif']:
  123. os.symlink('../../pylibs/%s' % lib_name, 'unittest/src/%s' % lib_name)
  124. os.mkdir('unittest/src/tests')
  125. with open('unittest/src/tests/__init__.py', 'w') as fh:
  126. fh.write(test_init_py)