diff --git a/.gitignore b/.gitignore index 7d00d6f..cac3041 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ venv.bak/ # vscode files +.vscode/ .vscode/settings.json # IDEA files diff --git a/.vscode/settings.json b/.vscode/settings.json index 4d6507c..6e87ce1 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -57,20 +57,21 @@ "python.autoComplete.extraPaths": [ "./src", "./mock", - "./test", + "./tests", "./venv2/bin", "./venv2/Lib/python2.7/site-packages", // "./venv/bin", // "./venv/Lib/python3.7/site-packages", ], + "python.envFile": "${workspaceFolder}/.env", "python.pythonPath": "venv2/bin/python", "python.formatting.provider": "yapf", "python.formatting.yapfArgs": [ "--style", "{based_on_style: pep8 ,indent_width: 4, column_limit: 130}", ], - "python.languageServer": "Jedi", + // "python.languageServer": "Jedi", + "python.languageServer": "Pylance", // "python.languageServer": "Microsoft", - // "python.languageServer": "Pylance", "python.linting.enabled": true, "python.linting.flake8Enabled": true, "python.linting.flake8Args": [ @@ -84,7 +85,7 @@ "python.testing.unittestArgs": [ "-v", "-s", - "./test", + "./tests", "-p", "test_*.py" ], @@ -92,6 +93,7 @@ "python.testing.cwd": "${workspaceFolder}", "python.testing.nosetestsEnabled": false, "python.testing.pytestEnabled": false, + "python.testing.promptToConfigure": true, "python.testing.unittestEnabled": true, "workbench.iconTheme": "vscode-icons", "workbench.editor.enablePreview": true, diff --git a/README.md b/README.md index 831cf88..9fe2d60 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,10 @@ - [4.1 python version](#41-python-version) - [4.2 pip setuptools wheel version](#42-pip-setuptools-wheel-version) - [4.2.1 pip freeze list](#421-pip-freeze-list) - - [4.2.2 setuptools](#422-setuptools) - - [4.2.2.1 setup.cfg](#4221-setupcfg) - - [4.2.2.2 setup.py](#4222-setuppy) + - [4.2.2 pip cache](#422-pip-cache) + - [4.2.3 setuptools](#423-setuptools) + - [4.2.3.1 setup.cfg](#4231-setupcfg) + - [4.2.3.2 setup.py](#4232-setuppy) - [4.3 virtualenv version](#43-virtualenv-version) - [4.4 tox tox-travis version](#44-tox-tox-travis-version) - [4.5 twine version](#45-twine-version) @@ -35,7 +36,8 @@ - [5.2.2 MANIFEST.in](#522-manifestin) - [5.2.3 tox.ini](#523-toxini) - [5.2.4 setup.cfg](#524-setupcfg) - - [5.2.5 README.md](#525-readmemd) + - [5.2.5 setup.py](#525-setuppy) + - [5.2.6 README.md](#526-readmemd) - [5.3 构建](#53-构建) - [5.3.1 tox 脚本测试](#531-tox-脚本测试) - [5.3.2 build](#532-build) @@ -212,9 +214,23 @@ python2 -m pip freeze > ./Temp/python_pip_freeze.txt python2 -m pip list > ./Temp/python_pip_list.txt ``` -#### 4.2.2 setuptools +#### 4.2.2 pip cache -##### 4.2.2.1 setup.cfg +```bash +# pip cache list +python2 -m pip cache list > ./out/dist/pip_cache_list.txt +python3 -m pip cache list > ./out/dist/pip_cache_list.txt +# pip no cache install +python2 -m pip --no-cache-dir install com.dvsnier.* +python3 -m pip --no-cache-dir install com.dvsnier.* +# pip remove cache package with whl +python2 -m pip cache remove com.dvsnier.* +python3 -m pip cache remove com.dvsnier.* +``` + +#### 4.2.3 setuptools + +##### 4.2.3.1 setup.cfg ```bash # python2 build @@ -230,7 +246,7 @@ python3 -m build python3 -m build > ./out/dist/build.txt ``` -##### 4.2.2.2 setup.py +##### 4.2.3.2 setup.py ```bash # setup sdist @@ -469,14 +485,14 @@ commands = # 1. https://setuptools.readthedocs.io/en/latest/ # 2. https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html # 3. https://setuptools.readthedocs.io/en/latest/references/keywords.html -name = com.dvsnier.directory +name = com.dvsnier.xxx version = 0.0.1.dev1 author = dvsnier author_email = dovsnier@qq.com description = this is dvsnier directory. long_description = file: ./doc/description/directory/README.md long_description_content_type = text/markdown -keywords = dir, development +keywords = xxx, development url = https://github.com/Alinvor/Python-DeMo project_urls = Documentation = https://packaging.python.org/tutorials/distributing-packages/ @@ -527,7 +543,321 @@ universal = 1 实际项目中, 可依据如上配置信息稍加修改和增添; -#### 5.2.5 README.md +#### 5.2.5 setup.py + +最后配置 `setup.py` 构建脚本, 指定软件包所要构建的软件细节部分, 举例配置信息如下: + +```bash +# -*- coding:utf-8 -*- +"""A setuptools based setup module. + +See: +https://packaging.python.org/guides/distributing-packages-using-setuptools/ +https://github.com/Alinvor/Python-DeMo +""" + +# Always prefer setuptools over distutils +from setuptools import setup, find_packages +import os +import sys + + +def read_text(file_name): + ''' the read describe readme files content. ''' + content = '' + with open(file_name, 'r') as file: + lines = file.readlines() + for line in lines: + if sys.version_info.major > 2: + content += str(line) + else: + content += str(line).encode('utf-8') + # print(content) + return content +# +# the repaired your home name +# +PROJECT_PREFIX = '/Users/.../Python-DeMo/' +project = PROJECT_PREFIX +print(project) +PROJECT_DIRECTORY = 'directory' # project directory +PROJECT_README_FILE = 'README.md' # project readme file +README_ROOT_DIRECTORY = os.path.join(project, 'doc/description') +README_PROJECT_DIRECTORY = os.path.join(README_ROOT_DIRECTORY, PROJECT_DIRECTORY) +PROJECT_DESCRIPTION = os.path.join(README_PROJECT_DIRECTORY, PROJECT_README_FILE) +# +# Arguments marked as "Required" below must be included for upload to PyPI. +# Fields marked as "Optional" may be commented out. +# +# | 序列 | 字段 | 数据类型 | 选项 | 描述 | 备注 | +# | :---: | :-----------------------------------: | :---------: | :---: | -------------------- | ---- | +# | 1 | DVSNIER_NAME | string | Y | 包名称 | | +# | 2 | DVSNIER_VERSION | string | Y | 包版本 | | +# | 3 | DVSNIER_DESCRIPTOIN | string | | 包简单描述 | | +# | 4 | DVSNIER_LONG_DESCRIPTOIN | file | | 较长文档描述 | | +# | 5 | DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE | string | | 长文本类型描述 | | +# | 6 | DVSNIER_URL | http | | 项目主页 | | +# | 7 | DVSNIER_AUTHOR | string | | 项目作者 | | +# | 8 | DVSNIER_AUTHOR_EMAIL | email | | 项目作者邮箱 | | +# | 9 | DVSNIER_LICENSE | 许可证 | | 许可证 | | +# | 10 | DVSNIER_CLASSIFIERS | classifiers | | 项目分类器 | | +# | 11 | DVSNIER_KEYWORDS | keywords | | 项目关键字 | | +# | 12 | DVSNIER_PACKAGE_DIR | string | | 包目录 | | +# | 13 | DVSNIER_PY_MODULES | string | Y | 模块名称 | | +# | 14 | DVSNIER_PACKAGES | string | Y | 包名称 | | +# | 15 | DVSNIER_PYTHON_REQUIRES | string | Y | 版本匹配分类器描述符 | | +# | 16 | DVSNIER_INSTALL_REQUIRES | list | | 依赖库 | | +# | 17 | DVSNIER_EXTRAS_REQUIRE | dict | | 附加/扩展依赖 | | +# | 18 | DVSNIER_PACKAGE_DATA | dict | | 包数据文件 | | +# | 19 | DVSNIER_DATA_FILES | list | | 包外数据文件 | | +# | 20 | DVSNIER_ENTRY_POINTS | dict | | 入口点 | | +# | 21 | DVSNIER_PROJECT_URLS | dict | | 项目 URL | | +# | 22 | | | | | | +DVSNIER_NAME = 'com.dvsnier.xxx' # Required +DVSNIER_VERSION = '0.0.1.dev1' # Required +DVSNIER_DESCRIPTOIN = 'this is dvsnier directory.' # Optional +# Get the long description from the README file +DVSNIER_LONG_DESCRIPTOIN = read_text(str(PROJECT_DESCRIPTION)) # Optional +DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE = 'text/markdown' # Optional +DVSNIER_URL = 'https://github.com/Alinvor/Python-DeMo' # Optional +DVSNIER_AUTHOR = 'dvsnier' # Optional +DVSNIER_AUTHOR_EMAIL = 'dovsnier@qq.com' # Optional +DVSNIER_LICENSE = 'MIT' # Optional +DVSNIER_CLASSIFIERS = [ # Optional + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + 'Development Status :: 3 - Alpha', + + # Indicate who your project is intended for + # 'Intended Audience :: Developers', + # 'Topic :: Software Development :: Build Tools', + + # Pick your license as you wish + 'License :: OSI Approved :: MIT License', + + # Specify the Python versions you support here. In particular, ensure + # that you indicate you support Python 3. These classifiers are *not* + # checked by 'pip install'. See instead 'python_requires' below. + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + # 'Programming Language :: Python :: 3 :: Only', + 'Operating System :: OS Independent' +] +DVSNIER_KEYWORDS = 'xxx, development' # Optional +DVSNIER_PACKAGE_DIR = {'': 'src'} # Optional +# DVSNIER_PY_MODULES = ["xxx"] # Required +# DVSNIER_PACKAGES = find_packages(include=['xxx', 'xxx.*']) # Required +DVSNIER_PACKAGES = find_packages(where='src') # Required +# DVSNIER_PYTHON_REQUIRES = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*' +DVSNIER_PYTHON_REQUIRES = '>=2.7, <4' +DVSNIER_INSTALL_REQUIRES = [ # Optional + # 'discover==0.4.0', + # 'build==0.4.0', + # 'pathlib2==2.3.5', + # 'toml==0.10.2', + # 'twine==1.15.0', +] +DVSNIER_EXTRAS_REQUIRE = { # Optional + 'dev': ['check-manifest'], + 'test': ['coverage'] +} +DVSNIER_PACKAGE_DATA = { # Optional + # 'sample': ['package_data.dat'], +} +DVSNIER_DATA_FILES = [ # Optional + # ('my_data', ['data/data_file']) +] +DVSNIER_ENTRY_POINTS = { # Optional + # 'console_scripts': [ + # 'dvs-dir=dvs:main', + # ], +} +DVSNIER_PROJECT_URLS = { # Optional + 'Bug_Tracker': 'https://github.com/Alinvor/Python-DeMo/issues', + 'Documentation': 'https://packaging.python.org/tutorials/distributing-packages/', + 'Funding': 'https://donate.pypi.org', + 'Wiki': 'https://github.com/Alinvor/Python-DeMo/wiki', + 'Source': 'https://github.com/Alinvor/Python-DeMo' +} + +setup( + # This is the name of your project. The first time you publish this + # package, this name will be registered for you. It will determine how + # users can install this project, e.g.: + # + # $ pip install com.dvsnier.xxx + # + # And where it will live on PyPI: https://pypi.org/project/com.dvsnier.xxx/ + # + # There are some restrictions on what makes a valid project name + # specification here: + # https://packaging.python.org/specifications/core-metadata/#name + name=DVSNIER_NAME, # Required + + # Versions should comply with PEP 440: + # https://www.python.org/dev/peps/pep-0440/ + # https://semver.org/lang/zh-CN/ + # + # 1.2.0.dev1 Development release + # 1.2.0a1 Alpha Release + # 1.2.0b1 Beta Release + # 1.2.0rc1 Release Candidate + # 1.2.0 Final Release + # 1.2.0.post1 Post Release + # 15.10 Date based release + # 23 Serial release + # + # For a discussion on single-sourcing the version across setup.py and the + # project code, see + # https://packaging.python.org/en/latest/single_source_version.html + version=DVSNIER_VERSION, # Required + + # This is a one-line description or tagline of what your project does. This + # corresponds to the "Summary" metadata field: + # https://packaging.python.org/specifications/core-metadata/#summary + description=DVSNIER_DESCRIPTOIN, # Optional + + # This is an optional longer description of your project that represents + # the body of text which users will see when they visit PyPI. + # + # Often, this is the same as your README, so you can just read it in from + # that file directly (as we have already done above) + # + # This field corresponds to the "Description" metadata field: + # https://packaging.python.org/specifications/core-metadata/#description-optional + long_description=DVSNIER_LONG_DESCRIPTOIN, # Optional + + # Denotes that our long_description is in Markdown; valid values are + # text/plain, text/x-rst, and text/markdown + # + # Optional if long_description is written in reStructuredText (rst) but + # required for plain-text or Markdown; if unspecified, "applications should + # attempt to render [the long_description] as text/x-rst; charset=UTF-8 and + # fall back to text/plain if it is not valid rst" (see link below) + # + # This field corresponds to the "Description-Content-Type" metadata field: + # https://packaging.python.org/specifications/core-metadata/#description-content-type-optional + long_description_content_type=DVSNIER_LONG_DESCRIPTION_CONTENT_TYPE, # Optional (see note above) + + # This should be a valid link to your project's main homepage. + # + # This field corresponds to the "Home-Page" metadata field: + # https://packaging.python.org/specifications/core-metadata/#home-page-optional + url=DVSNIER_URL, # Optional + + # This should be your name or the name of the organization which owns the project. + author=DVSNIER_AUTHOR, # Optional + + # This should be a valid email address corresponding to the author listed above. + author_email=DVSNIER_AUTHOR_EMAIL, # Optional + + # The license argument doesn’t have to indicate the license under which your package is being released, + # although you may optionally do so if you want. If you’re using a standard, well-known license, then + # your main indication can and should be via the classifiers argument. Classifiers exist for all major + # open-source licenses. + license=DVSNIER_LICENSE, # Optional + + # Classifiers help users find your project by categorizing it. + # + # For a list of valid classifiers, see https://pypi.org/classifiers/ + classifiers=DVSNIER_CLASSIFIERS, # Optional + + # This field adds keywords for your project which will appear on the + # project page. What does your project relate to? + # + # Note that this is a list of additional keywords, separated + # by commas, to be used to assist searching for the distribution in a + # larger catalog. + keywords=DVSNIER_KEYWORDS, # Optional + + # When your source code is in a subdirectory under the project root, e.g. + # `src/`, it is necessary to specify the `package_dir` argument. + package_dir=DVSNIER_PACKAGE_DIR, # Optional + + # You can just specify package directories manually here if your project is + # simple. Or you can use find_packages(). + # + # Alternatively, if you just want to distribute a single Python file, use + # the `py_modules` argument instead as follows, which will expect a file + # called `my_module.py` to exist: + # + # py_modules=["my_module"], + # + packages=DVSNIER_PACKAGES, # Required + + # If your project contains any single-file Python modules that aren’t part of + # a package, set py_modules to a list of the names of the modules (minus the .py + # extension) in order to make setuptools aware of them. + # py_modules=DVSNIER_PY_MODULES, # Required + + # Specify which Python versions you support. In contrast to the + # 'Programming Language' classifiers above, 'pip install' will check this + # and refuse to install the project if the version does not match. See + # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires + python_requires=DVSNIER_PYTHON_REQUIRES, + + # This field lists other packages that your project depends on to run. + # Any package you put here will be installed by pip when your project is + # installed, so they must be valid existing projects. + # + # For an analysis of "install_requires" vs pip's requirements files see: + # https://packaging.python.org/en/latest/requirements.html + # https://packaging.python.org/discussions/install-requires-vs-requirements/ + install_requires=DVSNIER_INSTALL_REQUIRES, # Optional + + # List additional groups of dependencies here (e.g. development + # dependencies). Users will be able to install these using the "extras" + # syntax, for example: + # + # $ pip install sampleproject[dev] + # + # Similar to `install_requires` above, these must be valid existing projects. + extras_require=DVSNIER_EXTRAS_REQUIRE, # Optional + + # If there are data files included in your packages that need to be + # installed, specify them here. + # https://setuptools.readthedocs.io/en/latest/userguide/datafiles.html + package_data=DVSNIER_PACKAGE_DATA, # Optional + + # Although 'package_data' is the preferred approach, in some case you may + # need to place data files outside of your packages. See: + # http://docs.python.org/distutils/setupscript.html#installing-additional-files + # http://docs.python.org/3/distutils/setupscript.html#installing-additional-files + # + # In this case, 'data_file' will be installed into '/my_data' + data_files=DVSNIER_DATA_FILES, # Optional + + # To provide executable scripts, use entry points in preference to the + # "scripts" keyword. Entry points provide cross-platform support and allow + # `pip` to create the appropriate form of executable for the target + # platform. + # + # For example, the following would provide a command called `dvsnier` which + # executes the function `main` from this package when invoked: + entry_points=DVSNIER_ENTRY_POINTS, # Optional + + # List additional URLs that are relevant to your project as a dict. + # + # This field corresponds to the "Project-URL" metadata fields: + # https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use + # + # Examples listed include a pattern for specifying where the package tracks + # issues, where the source is hosted, where to say thanks to the package + # maintainers, and where to support the project financially. The key is + # what's used to render the link text on PyPI. + project_urls=DVSNIER_PROJECT_URLS, # Optional +) + +``` + +> 软件包`名称`和软件包`版本`信息, 一定要明确具体发布规则; + +实际项目中, 可依据如上配置信息稍加修改和增添; + +#### 5.2.6 README.md 更新`README.md` 版本和摘要信息; diff --git a/case/file/test_strip.py b/case/file/test_strip.py index 33a97b0..503b547 100644 --- a/case/file/test_strip.py +++ b/case/file/test_strip.py @@ -12,9 +12,7 @@ def read_file(file_name): if len(line.strip()) > 0: index += 1 md_line_text = line.strip().split('[') - line_text = str( - str(index) + '. [' + md_line_text[1] + - md_line_text[0]).encode('utf-8') + line_text = str(str(index) + '. [' + md_line_text[1] + md_line_text[0]).encode('utf-8') content.append(line_text) # print(line_text) dir_name = os.path.dirname(file_name) @@ -22,7 +20,8 @@ def read_file(file_name): if len(content) > 0: with open(dest_name, 'w') as file: for item in content: - file.write(str(item).encode('utf-8') + '\n') + # file.write(str(item).encode('utf-8') + '\n') + file.write(str(item, 'utf-8') + '\n') if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c90cf55 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,12 @@ +# +# 1. https://setuptools.readthedocs.io/en/latest/ +# 2. https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html +# +# +# https://packaging.python.org/guides/distributing-packages-using-setuptools/#wheels +# +[bdist_wheel] +universal = 1 + +[flake8] +max-line-length = 120 diff --git a/template/__init__with_pkgutil.py b/template/__init__with_pkgutil.py new file mode 100644 index 0000000..d9abd92 --- /dev/null +++ b/template/__init__with_pkgutil.py @@ -0,0 +1,2 @@ +# -*- coding:utf-8 -*- +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/template/test_template.py b/template/test_template.py index ff98375..647d752 100644 --- a/template/test_template.py +++ b/template/test_template.py @@ -14,7 +14,7 @@ def setUp(self): return super(Test_XXX, self).setUp() def test_xxx(self): - print "the test xxx is succeed." + print ("the test xxx(test_template.py) is succeed.") pass def tearDown(self): diff --git a/test/com/dvsnier/conf/test_common_conf.py b/test/com/dvsnier/conf/test_common_conf.py deleted file mode 100644 index 333df55..0000000 --- a/test/com/dvsnier/conf/test_common_conf.py +++ /dev/null @@ -1,192 +0,0 @@ -# -*- coding:utf-8 -*- - -import unittest -from com.dvsnier.conf.common_conf import Conf, logging_conf -from com.dvsnier.dir.common_dir import generate_file_name_only, mk_dir - - -class Test_Common_Conf(unittest.TestCase): - ''' the test common conf ''' - - _Conf = None - test_config_dir = None - file_name = None - - @classmethod - def setUpClass(cls): - print("...the set up...") - print - - def setUp(self): - self._Conf = Conf() - self.test_config_dir = mk_dir('conf') - self.file_name = generate_file_name_only(self.test_config_dir, - 'test_config.cfg') - return super(Test_Common_Conf, self).setUp() - - def test_logging_conf(self): - 'the test logging conf' - # kwargs = {'output_dir_name': ' ', 'file_name': ' '} - # kwargs = {'output_dir_name': 'request', 'file_name': ' '} - # kwargs = {'output_dir_name': ' ', 'file_name': 'request'} - kwargs = {'output_dir_name': 'request', 'file_name': 'request'} - logging_conf(kwargs) - print "the test test_logging_conf is succeed." - - def test_conf(self): - 'the test conf' - self.assertIsNotNone(self._Conf, 'test_conf is error.') - - def test_conf_1_write(self): - 'the test conf write' - self._Conf.set('test_conf_write', 'test1', 'test1') - self._Conf.set('test_conf_write', 'test2', 'test2') - self._Conf.write(self.file_name) - print "the test test_conf_1_write is succeed." - # self.debug() - - def test_conf_2_read(self): - 'the test conf read' - self._Conf.read(self.file_name) - self.assertIsNotNone(self._Conf.sections(), - 'test_conf_2_read is error.') - print "the test test_conf_2_read is succeed." - # self.debug() - - def test_conf_3_add_section(self): - 'the test conf add section' - # - # 测试用例不是按照代码从上往下有序执行,而是指令重排列(字母表) - # - self._Conf.add_section('test_conf_add_section') - self._Conf.set('test_conf_add_section', 'test1', '1') - self._Conf.set('test_conf_add_section', 'test2', '2') - self._Conf.write(self.file_name) - self.assertIsNotNone(self._Conf.sections(), - 'test_conf_3_add_section is error.') - print "the test test_conf_3_add_section is succeed." - # self.debug() - - def test_conf_4_remove_section(self): - 'the test conf remove section' - self._Conf.add_section('test_conf_remove_section') - self._Conf.remove_section('test_conf_remove_section') - self._Conf.write(self.file_name) - self.assertIsNotNone(self._Conf.sections(), - 'test_conf_4_remove_section is error.') - print "the test test_conf_4_remove_section is succeed." - # self.debug() - - def test_conf_5_sections(self): - 'the test conf sections' - self._Conf.read(self.file_name) - # self._Conf.set('test_conf_write', 'test1', 'test1') - # self._Conf.set('test_conf_write', 'test2', 'test2') - self.assertIsNotNone(self._Conf.sections(), - 'test_conf_5_sections is error.') - print "the test test_conf_5_sections is succeed." - # self.debug() - - def test_conf_6_options(self): - 'the test conf options' - self._Conf.read(self.file_name) - self._Conf.set('test_conf_add_section', 'test1', 'test1') - self.assertIsNotNone(self._Conf.options('test_conf_add_section'), - 'test_conf_6_options is error.') - print "the test test_conf_6_options is succeed." - # self.debug() - - def test_conf_7_get(self): - 'the test conf options that get value' - self._Conf.read(self.file_name) - self._Conf.set('test_conf_get', 'test1', 'test1') - self.assertIsNotNone(self._Conf.get('test_conf_get', 'test1'), - 'test_conf_7_get is error.') - print "the test test_conf_7_get is succeed." - # self.debug() - - def test_conf_8_getboolean(self): - 'the test conf options that get boolean value' - self._Conf.read(self.file_name) - self._Conf.set('test_conf_getboolean', 'test0', 'getboolean') - self._Conf.set('test_conf_getboolean', 'test1', 'true') - self._Conf.set('test_conf_getboolean', 'test2', 'True') - self._Conf.set('test_conf_getboolean', 'test3', '0') - self._Conf.set('test_conf_getboolean', 'test4', '1') - self._Conf.set('test_conf_getboolean', 'test5', 'false') - self._Conf.set('test_conf_getboolean', 'test6', 'False') - self.assertTrue(self._Conf.getboolean('test_conf_getboolean', 'test1'), - 'test_conf_8_getboolean is error.') - self.assertTrue(self._Conf.getboolean('test_conf_getboolean', 'test2'), - 'test_conf_8_getboolean is error.') - self.assertFalse( - self._Conf.getboolean('test_conf_getboolean', 'test3'), - 'test_conf_8_getboolean is error.') - self.assertTrue(self._Conf.getboolean('test_conf_getboolean', 'test4'), - 'test_conf_8_getboolean is error.') - self.assertFalse( - self._Conf.getboolean('test_conf_getboolean', 'test5'), - 'test_conf_8_getboolean is error.') - self.assertFalse( - self._Conf.getboolean('test_conf_getboolean', 'test6'), - 'test_conf_8_getboolean is error.') - self.assertIsNotNone( - self._Conf.getboolean('test_conf_getboolean', 'test1'), - 'test_conf_8_getboolean is error.') - print "the test test_conf_8_getboolean is succeed." - # self.debug() - - def test_conf_9_getfloat(self): - 'the test conf options that get float value' - self._Conf.read(self.file_name) - self._Conf.set('test_conf_getfloat', 'test0', 'getfloat') - self._Conf.set('test_conf_getfloat', 'test1', '0') - self._Conf.set('test_conf_getfloat', 'test2', '1') - self._Conf.set('test_conf_getfloat', 'test3', '2') - self._Conf.set('test_conf_getfloat', 'test4', '3.0') - self._Conf.set('test_conf_getfloat', 'test5', '-1') - self._Conf.set('test_conf_getfloat', 'test6', '-1.2') - self.assertIsNotNone( - self._Conf.getfloat('test_conf_getfloat', 'test1'), - 'test_conf_9_getfloat is error.') - print "the test test_conf_9_getfloat is succeed." - # self.debug() - - def test_conf_10_getint(self): - 'the test conf options that get int value' - self._Conf.read(self.file_name) - self._Conf.set('test_conf_getint', 'test0', 'getint') - self._Conf.set('test_conf_getint', 'test1', '0') - self._Conf.set('test_conf_getint', 'test2', '1') - self._Conf.set('test_conf_getint', 'test3', '2') - self._Conf.set('test_conf_getint', 'test4', '3.0') - self._Conf.set('test_conf_getint', 'test5', '-1') - self._Conf.set('test_conf_getint', 'test6', '-1.2') - self.assertIsNotNone(self._Conf.getint('test_conf_getint', 'test1'), - 'test_conf_10_getint is error.') - print "the test test_conf_10_getint is succeed." - # self.debug() - - def debug(self): - 'the debug mode' - for section_element in self._Conf.sections(): - options = self._Conf.options(section_element) - for option_element in options: - print('\noption: %s, key: %s, value: %s' % - (section_element, option_element, - self._Conf.get(section_element, option_element))) - # else: - # print('\noption: %s, key: %s, value: %s' % - # (section_element, 'None', 'None')) - - def tearDown(self): - return super(Test_Common_Conf, self).tearDown() - - @classmethod - def tearDownClass(cls): - print - print("...the tear down...") - - -if __name__ == '__main__': - unittest.main() diff --git a/test/com/dvsnier/git/remote/__init__.py b/test/com/dvsnier/git/remote/__init__.py deleted file mode 100644 index 380474e..0000000 --- a/test/com/dvsnier/git/remote/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding:utf-8 -*- diff --git a/test/com/dvsnier/http/__init__.py b/test/com/dvsnier/http/__init__.py deleted file mode 100644 index 380474e..0000000 --- a/test/com/dvsnier/http/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding:utf-8 -*- diff --git a/test/com/dvsnier/process/__init__.py b/test/com/dvsnier/process/__init__.py deleted file mode 100644 index 380474e..0000000 --- a/test/com/dvsnier/process/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding:utf-8 -*- diff --git a/test/com/__init__.py b/tests/__init__.py similarity index 100% rename from test/com/__init__.py rename to tests/__init__.py diff --git a/test/case/case_1.py b/tests/case/case_1.py similarity index 100% rename from test/case/case_1.py rename to tests/case/case_1.py diff --git a/test/com/dvsnier/dir/test_common_dir.py b/tests/com/dvsnier/dir/test_common_dir.py similarity index 100% rename from test/com/dvsnier/dir/test_common_dir.py rename to tests/com/dvsnier/dir/test_common_dir.py diff --git a/test/com/dvsnier/__init__.py b/tests/com/dvsnier/git/__init__.py similarity index 100% rename from test/com/dvsnier/__init__.py rename to tests/com/dvsnier/git/__init__.py diff --git a/test/com/dvsnier/conf/__init__.py b/tests/com/dvsnier/git/branch/__init__.py similarity index 100% rename from test/com/dvsnier/conf/__init__.py rename to tests/com/dvsnier/git/branch/__init__.py diff --git a/test/com/dvsnier/git/branch/test_branch.py b/tests/com/dvsnier/git/branch/test_branch.py similarity index 100% rename from test/com/dvsnier/git/branch/test_branch.py rename to tests/com/dvsnier/git/branch/test_branch.py diff --git a/test/com/dvsnier/dir/__init__.py b/tests/com/dvsnier/git/checkout/__init__.py similarity index 100% rename from test/com/dvsnier/dir/__init__.py rename to tests/com/dvsnier/git/checkout/__init__.py diff --git a/test/com/dvsnier/git/checkout/test_checkout.py b/tests/com/dvsnier/git/checkout/test_checkout.py similarity index 100% rename from test/com/dvsnier/git/checkout/test_checkout.py rename to tests/com/dvsnier/git/checkout/test_checkout.py diff --git a/test/com/dvsnier/git/__init__.py b/tests/com/dvsnier/git/config/__init__.py similarity index 100% rename from test/com/dvsnier/git/__init__.py rename to tests/com/dvsnier/git/config/__init__.py diff --git a/test/com/dvsnier/git/config/test_config.py b/tests/com/dvsnier/git/config/test_config.py similarity index 100% rename from test/com/dvsnier/git/config/test_config.py rename to tests/com/dvsnier/git/config/test_config.py diff --git a/test/com/dvsnier/git/branch/__init__.py b/tests/com/dvsnier/git/pull/__init__.py similarity index 100% rename from test/com/dvsnier/git/branch/__init__.py rename to tests/com/dvsnier/git/pull/__init__.py diff --git a/test/com/dvsnier/git/pull/test_pull.py b/tests/com/dvsnier/git/pull/test_pull.py similarity index 100% rename from test/com/dvsnier/git/pull/test_pull.py rename to tests/com/dvsnier/git/pull/test_pull.py diff --git a/test/com/dvsnier/git/checkout/__init__.py b/tests/com/dvsnier/git/remote/__init__.py similarity index 100% rename from test/com/dvsnier/git/checkout/__init__.py rename to tests/com/dvsnier/git/remote/__init__.py diff --git a/test/com/dvsnier/git/remote/test_remote.py b/tests/com/dvsnier/git/remote/test_remote.py similarity index 100% rename from test/com/dvsnier/git/remote/test_remote.py rename to tests/com/dvsnier/git/remote/test_remote.py diff --git a/test/com/dvsnier/git/test_git.py b/tests/com/dvsnier/git/test_git.py similarity index 100% rename from test/com/dvsnier/git/test_git.py rename to tests/com/dvsnier/git/test_git.py diff --git a/test/com/dvsnier/git/config/__init__.py b/tests/com/dvsnier/http/__init__.py similarity index 100% rename from test/com/dvsnier/git/config/__init__.py rename to tests/com/dvsnier/http/__init__.py diff --git a/test/com/dvsnier/http/test_https.py b/tests/com/dvsnier/http/test_https.py similarity index 100% rename from test/com/dvsnier/http/test_https.py rename to tests/com/dvsnier/http/test_https.py diff --git a/test/com/dvsnier/git/pull/__init__.py b/tests/com/dvsnier/process/__init__.py similarity index 100% rename from test/com/dvsnier/git/pull/__init__.py rename to tests/com/dvsnier/process/__init__.py diff --git a/test/com/dvsnier/process/test_execute.py b/tests/com/dvsnier/process/test_execute.py similarity index 100% rename from test/com/dvsnier/process/test_execute.py rename to tests/com/dvsnier/process/test_execute.py diff --git a/test/demo_test.py b/tests/demo_test.py similarity index 100% rename from test/demo_test.py rename to tests/demo_test.py diff --git a/tox.ini b/tox.ini index f594360..3869a41 100644 --- a/tox.ini +++ b/tox.ini @@ -17,19 +17,32 @@ isolated_build = true # install testing framework # ... or install anything else you might need here [testenv] +passenv = + PYTHONPATH platform = linux: linux macos: darwin windows: win32 ; alwayscopy = True allowlist_externals = /bin/bash -changedir = - tests +; changedir = +; tests +# https://tox.readthedocs.io/en/latest/config.html#conf-deps deps = - build + unittest2 + flake8 + virtualenv + setuptools + wheel discover + tox + toml + tox-travis + build + twine commands = ; windows: python --version ; macos,linux: python --version - discover + discover -s ./tests -t . + ; unit2 discover [] ; python -m unittest discover