#!/usr/bin/env python # -*- coding: UTF-8 -*- import os import stat name = os.path.basename(os.path.abspath('.')) gitignore = """# general stuff *~ unittest/testresults/* unittest/output_data/* # eclipse stuff .settings/ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *,cover # Translations *.mo *.pot # Django stuff: *.log # Sphinx documentation docs/_build/ # PyBuilder target/ """ unittest_py = """#!/usr/bin/env python # -*- coding: utf-8 -*- # import optparse import os import report import unittest import tests parser = optparse.OptionParser("usage: %prog [clean|run|coverage|pdf|copy|release]") parser.add_option("-e", "--execution-level", dest="execution_level", default="full", help="sets the execution level [full | short | smoke | single]") (options, args) = parser.parse_args() if report.TCEL_REVERSE_NAMED.get(tests.execution_level, report.TCEL_FULL) < report.TCEL_REVERSE_NAMED.get(options.execution_level, report.TCEL_FULL): options.execution_level = tests.execution_level unittest.run.unittest(options, args, os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) """ config_py = """#!/usr/bin/env python # -*- coding: UTF-8 -*- import optparse import os import %s as lib release_unittest_version = 'xxx' lib_path = os.path.realpath(lib.__path__[0]) additional_loggers_to_catch = [] if __name__ == "__main__": parser = optparse.OptionParser("usage: %%prog [options] folder_for_document") parser.add_option("-p", "--path", dest="libpath", action="store_true", default=False, help="prints the library path") (options, args) = parser.parse_args() if options.libpath: print(lib_path) """ % name test_init_py = """#!/usr/bin/env python # -*- coding: UTF-8 -*- import %s from report import TCEL_FULL from report import TCEL_SHORT from report import TCEL_SINGLE from report import TCEL_SMOKE #from tests import test_ execution_level = 'full' def testrun(tcl): # # caching.property_cache_json # tcl.testCase('description', TCEL_FULL, test_.func, *args, **kwargs) """ % name with open('.gitignore', 'w') as fh: fh.write(gitignore) os.mkdir('docs') os.mkdir('examples') os.symlink('../pylibs/%s' % name, 'examples/%s' % name) os.mkdir('pylibs') os.mkdir('requirements') os.mkdir('unittest') os.symlink('../pylibs/unittest/unittest_flow.sh', 'unittest/unittest.sh') os.mkdir('unittest/input_data') os.mkdir('unittest/output_data') os.mkdir('unittest/src') with open('unittest/src/config.py', 'w') as fh: fh.write(config_py) with open('unittest/src/unittest.py', 'w') as fh: fh.write(unittest_py) for lib_name in [name, 'report', 'unittest', 'fstools', 'reqif']: os.symlink('../../pylibs/%s' % lib_name, 'unittest/src/%s' % lib_name) os.mkdir('unittest/src/tests') with open('unittest/src/tests/__init__.py', 'w') as fh: fh.write(test_init_py)