From f7857016b7674290dd5a59653f0d29b12becdcd7 Mon Sep 17 00:00:00 2001 From: Adam Bullmer Date: Wed, 5 Dec 2018 01:31:34 -0600 Subject: [PATCH 1/4] Switched to using pipenv for virtualenv management --- requirements.txt => .env | 0 Pipfile | 17 +++ Pipfile.lock | 243 +++++++++++++++++++++++++++++++++++++++ setup.py | 36 ------ tox.ini | 38 +++--- 5 files changed, 281 insertions(+), 53 deletions(-) rename requirements.txt => .env (100%) create mode 100644 Pipfile create mode 100644 Pipfile.lock delete mode 100644 setup.py diff --git a/requirements.txt b/.env similarity index 100% rename from requirements.txt rename to .env diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..ab5b198 --- /dev/null +++ b/Pipfile @@ -0,0 +1,17 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] +tox = "*" +flake8 = "*" +pytest = "*" +pytest-cov = "*" +pytest-sugar = "*" +pydocstyle = "*" + +[packages] + +[requires] +python_version = "3.4.3" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..12e414e --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,243 @@ +{ + "_meta": { + "hash": { + "sha256": "20348068f03e55e1da73d38d9e65c8ebca767771b5f0dff744f111de6e78e795" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.4.3" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": { + "atomicwrites": { + "hashes": [ + "sha256:0312ad34fcad8fac3704d441f7b317e50af620823353ec657a53e981f92920c0", + "sha256:ec9ae8adaae229e4f8446952d204a3e4b5fdd2d099f9be3aaf556120135fb3ee" + ], + "version": "==1.2.1" + }, + "attrs": { + "hashes": [ + "sha256:10cbf6e27dbce8c30807caf056c8eb50917e0eaafe86347671b57254006c3e69", + "sha256:ca4be454458f9dec299268d472aaa5a11f67a4ff70093396e1ceae9c76cf4bbb" + ], + "version": "==18.2.0" + }, + "coverage": { + "hashes": [ + "sha256:09e47c529ff77bf042ecfe858fb55c3e3eb97aac2c87f0349ab5a7efd6b3939f", + "sha256:0a1f9b0eb3aa15c990c328535655847b3420231af299386cfe5efc98f9c250fe", + "sha256:0cc941b37b8c2ececfed341444a456912e740ecf515d560de58b9a76562d966d", + "sha256:10e8af18d1315de936d67775d3a814cc81d0747a1a0312d84e27ae5610e313b0", + "sha256:1b4276550b86caa60606bd3572b52769860a81a70754a54acc8ba789ce74d607", + "sha256:1e8a2627c48266c7b813975335cfdea58c706fe36f607c97d9392e61502dc79d", + "sha256:2b224052bfd801beb7478b03e8a66f3f25ea56ea488922e98903914ac9ac930b", + "sha256:447c450a093766744ab53bf1e7063ec82866f27bcb4f4c907da25ad293bba7e3", + "sha256:46101fc20c6f6568561cdd15a54018bb42980954b79aa46da8ae6f008066a30e", + "sha256:4710dc676bb4b779c4361b54eb308bc84d64a2fa3d78e5f7228921eccce5d815", + "sha256:510986f9a280cd05189b42eee2b69fecdf5bf9651d4cd315ea21d24a964a3c36", + "sha256:5535dda5739257effef56e49a1c51c71f1d37a6e5607bb25a5eee507c59580d1", + "sha256:5a7524042014642b39b1fcae85fb37556c200e64ec90824ae9ecf7b667ccfc14", + "sha256:5f55028169ef85e1fa8e4b8b1b91c0b3b0fa3297c4fb22990d46ff01d22c2d6c", + "sha256:6694d5573e7790a0e8d3d177d7a416ca5f5c150742ee703f3c18df76260de794", + "sha256:6831e1ac20ac52634da606b658b0b2712d26984999c9d93f0c6e59fe62ca741b", + "sha256:77f0d9fa5e10d03aa4528436e33423bfa3718b86c646615f04616294c935f840", + "sha256:828ad813c7cdc2e71dcf141912c685bfe4b548c0e6d9540db6418b807c345ddd", + "sha256:85a06c61598b14b015d4df233d249cd5abfa61084ef5b9f64a48e997fd829a82", + "sha256:8cb4febad0f0b26c6f62e1628f2053954ad2c555d67660f28dfb1b0496711952", + "sha256:a5c58664b23b248b16b96253880b2868fb34358911400a7ba39d7f6399935389", + "sha256:aaa0f296e503cda4bc07566f592cd7a28779d433f3a23c48082af425d6d5a78f", + "sha256:ab235d9fe64833f12d1334d29b558aacedfbca2356dfb9691f2d0d38a8a7bfb4", + "sha256:b3b0c8f660fae65eac74fbf003f3103769b90012ae7a460863010539bb7a80da", + "sha256:bab8e6d510d2ea0f1d14f12642e3f35cefa47a9b2e4c7cea1852b52bc9c49647", + "sha256:c45297bbdbc8bb79b02cf41417d63352b70bcb76f1bbb1ee7d47b3e89e42f95d", + "sha256:d19bca47c8a01b92640c614a9147b081a1974f69168ecd494687c827109e8f42", + "sha256:d64b4340a0c488a9e79b66ec9f9d77d02b99b772c8b8afd46c1294c1d39ca478", + "sha256:da969da069a82bbb5300b59161d8d7c8d423bc4ccd3b410a9b4d8932aeefc14b", + "sha256:ed02c7539705696ecb7dc9d476d861f3904a8d2b7e894bd418994920935d36bb", + "sha256:ee5b8abc35b549012e03a7b1e86c09491457dba6c94112a2482b18589cc2bdb9" + ], + "version": "==4.5.2" + }, + "filelock": { + "hashes": [ + "sha256:b8d5ca5ca1c815e1574aee746650ea7301de63d87935b3463d26368b76e31633", + "sha256:d610c1bb404daf85976d7a82eb2ada120f04671007266b708606565dd03b5be6" + ], + "version": "==3.0.10" + }, + "flake8": { + "hashes": [ + "sha256:6a35f5b8761f45c5513e3405f110a86bea57982c3b75b766ce7b65217abe1670", + "sha256:c01f8a3963b3571a8e6bd7a4063359aff90749e160778e03817cd9b71c9e07d2" + ], + "index": "pypi", + "version": "==3.6.0" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "more-itertools": { + "hashes": [ + "sha256:c187a73da93e7a8acc0001572aebc7e3c69daf7bf6881a2cea10650bd4420092", + "sha256:c476b5d3a34e12d40130bc2f935028b5f636df8f372dc2c1c01dc19681b2039e", + "sha256:fcbfeaea0be121980e15bc97b3817b5202ca73d0eae185b4550cbfce2a3ebb3d" + ], + "version": "==4.3.0" + }, + "packaging": { + "hashes": [ + "sha256:0886227f54515e592aaa2e5a553332c73962917f2831f1b0f9b9f4380a4b9807", + "sha256:f95a1e147590f204328170981833854229bb2912ac3d5f89e2a8ccd2834800c9" + ], + "version": "==18.0" + }, + "pathlib2": { + "hashes": [ + "sha256:25199318e8cc3c25dcb45cbe084cc061051336d5a9ea2a12448d3d8cb748f742", + "sha256:5887121d7f7df3603bca2f710e7219f3eca0eb69e0b7cc6e0a022e155ac931a7" + ], + "markers": "python_version < '3.6'", + "version": "==2.3.3" + }, + "pluggy": { + "hashes": [ + "sha256:447ba94990e8014ee25ec853339faf7b0fc8050cdc3289d4d71f7f410fb90095", + "sha256:bde19360a8ec4dfd8a20dcb811780a30998101f078fc7ded6162f0076f50508f" + ], + "version": "==0.8.0" + }, + "py": { + "hashes": [ + "sha256:bf92637198836372b520efcba9e020c330123be8ce527e535d185ed4b6f45694", + "sha256:e76826342cefe3c3d5f7e8ee4316b80d1dd8a300781612ddbc765c17ba25a6c6" + ], + "version": "==1.7.0" + }, + "pycodestyle": { + "hashes": [ + "sha256:cbc619d09254895b0d12c2c691e237b2e91e9b2ecf5e84c26b35400f93dcfb83", + "sha256:cbfca99bd594a10f674d0cd97a3d802a1fdef635d4361e1a2658de47ed261e3a" + ], + "version": "==2.4.0" + }, + "pydocstyle": { + "hashes": [ + "sha256:2258f9b0df68b97bf3a6c29003edc5238ff8879f1efb6f1999988d934e432bd8", + "sha256:5741c85e408f9e0ddf873611085e819b809fca90b619f5fd7f34bd4959da3dd4", + "sha256:ed79d4ec5e92655eccc21eb0c6cf512e69512b4a97d215ace46d17e4990f2039" + ], + "index": "pypi", + "version": "==3.0.0" + }, + "pyflakes": { + "hashes": [ + "sha256:9a7662ec724d0120012f6e29d6248ae3727d821bba522a0e6b356eff19126a49", + "sha256:f661252913bc1dbe7fcfcbf0af0db3f42ab65aabd1a6ca68fe5d466bace94dae" + ], + "version": "==2.0.0" + }, + "pyparsing": { + "hashes": [ + "sha256:40856e74d4987de5d01761a22d1621ae1c7f8774585acae358aa5c5936c6c90b", + "sha256:f353aab21fd474459d97b709e527b5571314ee5f067441dc9f88e33eecd96592" + ], + "version": "==2.3.0" + }, + "pytest": { + "hashes": [ + "sha256:1d131cc532be0023ef8ae265e2a779938d0619bb6c2510f52987ffcba7fa1ee4", + "sha256:ca4761407f1acc85ffd1609f464ca20bb71a767803505bd4127d0e45c5a50e23" + ], + "index": "pypi", + "version": "==4.0.1" + }, + "pytest-cov": { + "hashes": [ + "sha256:513c425e931a0344944f84ea47f3956be0e416d95acbd897a44970c8d926d5d7", + "sha256:e360f048b7dae3f2f2a9a4d067b2dd6b6a015d384d1577c994a43f3f7cbad762" + ], + "index": "pypi", + "version": "==2.6.0" + }, + "pytest-sugar": { + "hashes": [ + "sha256:26cf8289fe10880cbbc130bd77398c4e6a8b936d8393b116a5c16121d95ab283", + "sha256:fcd87a74b2bce5386d244b49ad60549bfbc4602527797fac167da147983f58ab" + ], + "index": "pypi", + "version": "==0.9.2" + }, + "scandir": { + "hashes": [ + "sha256:04b8adb105f2ed313a7c2ef0f1cf7aff4871aa7a1883fa4d8c44b5551ab052d6", + "sha256:1444134990356c81d12f30e4b311379acfbbcd03e0bab591de2696a3b126d58e", + "sha256:1b5c314e39f596875e5a95dd81af03730b338c277c54a454226978d5ba95dbb6", + "sha256:346619f72eb0ddc4cf355ceffd225fa52506c92a2ff05318cfabd02a144e7c4e", + "sha256:44975e209c4827fc18a3486f257154d34ec6eaec0f90fef0cca1caa482db7064", + "sha256:61859fd7e40b8c71e609c202db5b0c1dbec0d5c7f1449dec2245575bdc866792", + "sha256:a5e232a0bf188362fa00123cc0bb842d363a292de7126126df5527b6a369586a", + "sha256:c14701409f311e7a9b7ec8e337f0815baf7ac95776cc78b419a1e6d49889a383", + "sha256:c7708f29d843fc2764310732e41f0ce27feadde453261859ec0fca7865dfc41b", + "sha256:c9009c527929f6e25604aec39b0a43c3f831d2947d89d6caaab22f057b7055c8", + "sha256:f5c71e29b4e2af7ccdc03a020c626ede51da471173b4a6ad1e904f2b2e04b4bd" + ], + "markers": "python_version < '3.5'", + "version": "==1.9.0" + }, + "six": { + "hashes": [ + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" + ], + "version": "==1.11.0" + }, + "snowballstemmer": { + "hashes": [ + "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", + "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89" + ], + "version": "==1.2.1" + }, + "termcolor": { + "hashes": [ + "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b" + ], + "version": "==1.1.0" + }, + "toml": { + "hashes": [ + "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", + "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e" + ], + "version": "==0.10.0" + }, + "tox": { + "hashes": [ + "sha256:513e32fdf2f9e2d583c2f248f47ba9886428c949f068ac54a0469cac55df5862", + "sha256:75fa30e8329b41b664585f5fb837e23ce1d7e6fa1f7811f2be571c990f9d911b" + ], + "index": "pypi", + "version": "==3.5.3" + }, + "virtualenv": { + "hashes": [ + "sha256:686176c23a538ecc56d27ed9d5217abd34644823d6391cbeb232f42bf722baad", + "sha256:f899fafcd92e1150f40c8215328be38ff24b519cd95357fa6e78e006c7638208" + ], + "version": "==16.1.0" + } + } +} diff --git a/setup.py b/setup.py deleted file mode 100644 index c634e8a..0000000 --- a/setup.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python -"""Setup Utils.""" - -if __name__ == '__main__': - import logging - - from pkg_resources import Requirement - from setuptools import setup, find_packages - - log = logging.getLogger(__name__) - - with open('requirements.txt') as f: - REQUIREMENTS = [] - for req in f.readlines(): - req = req.strip() - try: - Requirement.parse(req) - except: - log.warning('failed to parse `{0}` from requirements.txt, skipping\n'.format(req)) - continue - if len(req) is 0: - continue - REQUIREMENTS.append(req) - - setup( - name='DocBlockr Python', - version='1.6.1', - description='', - author='Adam Bullmer', - author_email='psycodrumfreak@gmail.com', - url='https://github.com/adambullmer/sublime_docblockr_python', - packages=find_packages(), - include_package_data=True, - install_requires=REQUIREMENTS, - zip_safe=False, - ) diff --git a/tox.ini b/tox.ini index 2b5c322..7e252d9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,25 +1,29 @@ [tox] -envlist = style -usedevelop = true +skipsdist = True -[testenv:style] -deps = - -r{toxinidir}/requirements.txt - flake8==2.4.0 - pep257==0.7.0 -commands = - flake8 --statistics --count - pep257 +[testenv] +install_command = + pipenv install --ignore-pipfile && \ + pipenv install --dev --ignore-pipfile && \ + pipenv --dev -r {packages} +list_dependencies_command = pipenv lock -r +whitelist_externals = + pipenv +setenv = + PYTHONPATH = {toxinidir} + PIPENV_DOTENV_LOCATION = {toxinidir}/tests/.env -[testenv:style-ci] -deps = - -r{toxinidir}/requirements.txt - flake8==2.4.0 - pep257==0.7.0 +[testenv:style] commands = - flake8 --statistics --count --output-file={envdir}/flake8.txt - pep257 + pipenv run flake8 + pipenv run pydocstyle [flake8] max-line-length = 120 max-complexity = 10 +tee = true +count = true +show-statistics = true + +[pydocstyle] +match = '(?!test_).*\.py|(?!conftest\.py)' From d9b02c4ddb4534f498bc4941c973f6176cd77c4c Mon Sep 17 00:00:00 2001 From: Adam Bullmer Date: Wed, 5 Dec 2018 01:33:27 -0600 Subject: [PATCH 2/4] Fixed errors due to updated linters --- DocblockrPython.py | 2 +- commands.py | 4 +++- parsers/parser.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DocblockrPython.py b/DocblockrPython.py index 40efa3d..822c0f3 100644 --- a/DocblockrPython.py +++ b/DocblockrPython.py @@ -14,7 +14,7 @@ def plugin_loaded(): - """The Sublime Text 3 entry point for plugins.""" + """Sublime Text 3 entry point for plugins.""" populate_registry() global plugin_is_loaded diff --git a/commands.py b/commands.py index e66f431..08e31ad 100644 --- a/commands.py +++ b/commands.py @@ -43,6 +43,7 @@ def escape(string): Returns: {String} String with escaped characters + """ return string.replace('$', r'\$').replace('{', r'\{').replace('}', r'\}') @@ -101,7 +102,7 @@ def run(self, edit): write(self.view, snippet) def initialize(self, view): - """Setup the command's settings. + """Set up the command's settings. Begins preparsing the file to gather some basic information. - Which parser to use @@ -141,6 +142,7 @@ def create_snippet(self, parsed_attributes): Returns: str -- sublime text formatted snippet string + """ project_formatter = self.project_settings.get('formatter', None) formatter = get_formatter(project_formatter or get_setting('formatter'))() diff --git a/parsers/parser.py b/parsers/parser.py index 8fe3517..50d6077 100644 --- a/parsers/parser.py +++ b/parsers/parser.py @@ -413,7 +413,9 @@ def process_variable(self, variable, hints=None): params['default'] = pieces[1].strip() params['name'] = variable - params['type'] = hints.get(variable, None) or guess_type_from_value(params.get('default')) or guess_type_from_name(variable) + params['type'] = hints.get(variable, None) or \ + guess_type_from_value(params.get('default')) or \ + guess_type_from_name(variable) return params From bf25c4ca49c26e3af9fa3e5b39943e6566ec6227 Mon Sep 17 00:00:00 2001 From: Adam Bullmer Date: Wed, 5 Dec 2018 01:34:08 -0600 Subject: [PATCH 3/4] Added dummy tests to make sure importing continues to work fine --- .coveragerc | 5 ++++ .gitignore | 2 ++ __init__.py | 1 + tests/.env | 0 tests/__init__.py | 1 + tests/conftest.py | 38 ++++++++++++++++++++++++ tests/formatters/__init__.py | 1 + tests/formatters/conftest.py | 49 +++++++++++++++++++++++++++++++ tests/formatters/test_PEP0257.py | 2 ++ tests/formatters/test_base.py | 2 ++ tests/formatters/test_docblock.py | 2 ++ tests/formatters/test_google.py | 2 ++ tests/formatters/test_numpy.py | 2 ++ tests/formatters/test_registry.py | 2 ++ tests/formatters/test_sphinx.py | 2 ++ tests/formatters/test_utils.py | 2 ++ tests/parsers/conftest.py | 7 +++++ tests/parsers/test_parser.py | 2 ++ tests/test_DocblockrPython.py | 2 ++ tests/test_commands.py | 2 ++ tox.ini | 18 ++++++++++++ 21 files changed, 144 insertions(+) create mode 100644 .coveragerc create mode 100644 __init__.py create mode 100644 tests/.env create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/formatters/__init__.py create mode 100644 tests/formatters/conftest.py create mode 100644 tests/formatters/test_PEP0257.py create mode 100644 tests/formatters/test_base.py create mode 100644 tests/formatters/test_docblock.py create mode 100644 tests/formatters/test_google.py create mode 100644 tests/formatters/test_numpy.py create mode 100644 tests/formatters/test_registry.py create mode 100644 tests/formatters/test_sphinx.py create mode 100644 tests/formatters/test_utils.py create mode 100644 tests/parsers/conftest.py create mode 100644 tests/parsers/test_parser.py create mode 100644 tests/test_DocblockrPython.py create mode 100644 tests/test_commands.py diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..b47d2b9 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +omit = + */__main__.py + tests/* + __init__.py diff --git a/.gitignore b/.gitignore index ebe21f8..c5541ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .tox *.sublime-package +pytest +.coverage diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..665818f --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +"""Docblockr Python.""" diff --git a/tests/.env b/tests/.env new file mode 100644 index 0000000..e69de29 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..28c805b --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Docblockr Python Unit Tests.""" diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..a6eb6a7 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,38 @@ +from unittest.mock import MagicMock, patch +import pytest + + +@pytest.fixture(autouse=True) +def sublime(request): + mock = MagicMock() + patcher = patch.dict('sys.modules', { + 'sublime': mock, + }) + patcher.start() + request.addfinalizer(patcher.stop) + + return mock + + +@pytest.fixture(autouse=True) +def sublime_plugin(request): + mock = MagicMock() + patcher = patch.dict('sys.modules', { + 'sublime_plugin': mock, + }) + patcher.start() + request.addfinalizer(patcher.stop) + + return mock + + +@pytest.fixture() +def root_commands(): + from .. import commands + return commands + + +@pytest.fixture() +def root_DocblockrPython(): + from .. import DocblockrPython + return DocblockrPython diff --git a/tests/formatters/__init__.py b/tests/formatters/__init__.py new file mode 100644 index 0000000..133ae80 --- /dev/null +++ b/tests/formatters/__init__.py @@ -0,0 +1 @@ +"""Docblockr Python Unit Tests -- Formatters.""" diff --git a/tests/formatters/conftest.py b/tests/formatters/conftest.py new file mode 100644 index 0000000..54b9be6 --- /dev/null +++ b/tests/formatters/conftest.py @@ -0,0 +1,49 @@ +import pytest + + +@pytest.fixture() +def formatter_base(): + from formatters import base + return base + + +@pytest.fixture() +def formatter_docblock(): + from formatters import docblock + return docblock + + +@pytest.fixture() +def formatter_google(): + from formatters import google + return google + + +@pytest.fixture() +def formatter_numpy(): + from formatters import numpy + return numpy + + +@pytest.fixture() +def formatter_PEP0257(): + from formatters import PEP0257 + return PEP0257 + + +@pytest.fixture() +def formatter_registry(): + from formatters import registry + return registry + + +@pytest.fixture() +def formatter_sphinx(): + from formatters import sphinx + return sphinx + + +@pytest.fixture() +def formatter_utils(): + from formatters import utils + return utils diff --git a/tests/formatters/test_PEP0257.py b/tests/formatters/test_PEP0257.py new file mode 100644 index 0000000..03a76a8 --- /dev/null +++ b/tests/formatters/test_PEP0257.py @@ -0,0 +1,2 @@ +def test_exists(formatter_PEP0257): + assert formatter_PEP0257 diff --git a/tests/formatters/test_base.py b/tests/formatters/test_base.py new file mode 100644 index 0000000..384702e --- /dev/null +++ b/tests/formatters/test_base.py @@ -0,0 +1,2 @@ +def test_exists(formatter_base): + assert formatter_base diff --git a/tests/formatters/test_docblock.py b/tests/formatters/test_docblock.py new file mode 100644 index 0000000..87ae392 --- /dev/null +++ b/tests/formatters/test_docblock.py @@ -0,0 +1,2 @@ +def test_exists(formatter_docblock): + assert formatter_docblock diff --git a/tests/formatters/test_google.py b/tests/formatters/test_google.py new file mode 100644 index 0000000..07f2635 --- /dev/null +++ b/tests/formatters/test_google.py @@ -0,0 +1,2 @@ +def test_exists(formatter_google): + assert formatter_google diff --git a/tests/formatters/test_numpy.py b/tests/formatters/test_numpy.py new file mode 100644 index 0000000..8f0bfc4 --- /dev/null +++ b/tests/formatters/test_numpy.py @@ -0,0 +1,2 @@ +def test_exists(formatter_numpy): + assert formatter_numpy diff --git a/tests/formatters/test_registry.py b/tests/formatters/test_registry.py new file mode 100644 index 0000000..d955e73 --- /dev/null +++ b/tests/formatters/test_registry.py @@ -0,0 +1,2 @@ +def test_exists(formatter_registry): + assert formatter_registry diff --git a/tests/formatters/test_sphinx.py b/tests/formatters/test_sphinx.py new file mode 100644 index 0000000..bc1288a --- /dev/null +++ b/tests/formatters/test_sphinx.py @@ -0,0 +1,2 @@ +def test_exists(formatter_sphinx): + assert formatter_sphinx diff --git a/tests/formatters/test_utils.py b/tests/formatters/test_utils.py new file mode 100644 index 0000000..361259d --- /dev/null +++ b/tests/formatters/test_utils.py @@ -0,0 +1,2 @@ +def test_exists(formatter_utils): + assert formatter_utils diff --git a/tests/parsers/conftest.py b/tests/parsers/conftest.py new file mode 100644 index 0000000..a6656fd --- /dev/null +++ b/tests/parsers/conftest.py @@ -0,0 +1,7 @@ +import pytest + + +@pytest.fixture() +def parser(): + from parsers import parser + return parser diff --git a/tests/parsers/test_parser.py b/tests/parsers/test_parser.py new file mode 100644 index 0000000..14bdcee --- /dev/null +++ b/tests/parsers/test_parser.py @@ -0,0 +1,2 @@ +def test_exists(parser): + assert parser diff --git a/tests/test_DocblockrPython.py b/tests/test_DocblockrPython.py new file mode 100644 index 0000000..565b8b3 --- /dev/null +++ b/tests/test_DocblockrPython.py @@ -0,0 +1,2 @@ +def test_exists(root_DocblockrPython): + assert root_DocblockrPython diff --git a/tests/test_commands.py b/tests/test_commands.py new file mode 100644 index 0000000..28e4da6 --- /dev/null +++ b/tests/test_commands.py @@ -0,0 +1,2 @@ +def test_exists(root_commands): + assert root_commands diff --git a/tox.ini b/tox.ini index 7e252d9..323ebfc 100644 --- a/tox.ini +++ b/tox.ini @@ -9,15 +9,33 @@ install_command = list_dependencies_command = pipenv lock -r whitelist_externals = pipenv + rm + mkdir setenv = PYTHONPATH = {toxinidir} PIPENV_DOTENV_LOCATION = {toxinidir}/tests/.env +[testenv:test] +commands = + rm -rf pytest + mkdir -p pytest/coverage + pipenv run py.test + [testenv:style] commands = pipenv run flake8 pipenv run pydocstyle +[pytest] +testpaths = tests +addopts = + -v + --cov . + --cov-config .coveragerc + --cov-report term-missing + --cov-report html:pytest/coverage + --junitxml pytest/junit.xml + [flake8] max-line-length = 120 max-complexity = 10 From 2746fd48c6cd3353bf881998716017e49657038f Mon Sep 17 00:00:00 2001 From: Adam Bullmer Date: Sun, 9 Dec 2018 12:14:13 -0600 Subject: [PATCH 4/4] updated readme --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index c5fa655..9ac663c 100644 --- a/README.md +++ b/README.md @@ -77,10 +77,43 @@ class MyFormatter(Base): **Note:** The console should yell at you if you didn't write all the abstract methods. Be sure to read the docs on the `Base` formatter to make sure you understand all the caveats of each formatter function. +Local Development +----------------- + +Below are the instructions to work on this repo locally. + +1. Clone the repo. +1. Uninstall the plugin from sublime text. +1. Symlink the github repo into your sublime text packages directory. + - Debian example: +```bash +ln -s $HOME/.config/sublime-text-3/Packages/Docblockr_Python +``` +1. There are no runtime dependencies +1. Pay attention to the sublime console ```ctrl + ` ``` + + +Testing Changes +--------------- + +In addition to the setup instructions above, testing will require additinoal setup. + +**System Requirements:** +- [pyenv](https://github.com/pyenv/pyenv) +- [pipenv](https://pipenv.readthedocs.io/en/latest/) + +**Setup:** +1. Install depedencies through pipenv `pipenv install --dev` +1. Run unit tests `pipenv run tox` + - [py.test](https://docs.pytest.org/en/latest/) unit tests + - [flake8](http://flake8.pycqa.org/en/latest/) linting + - [pydocstyle](http://www.pydocstyle.org/en/2.1.1/) (formerly PEP257) docstring checker + Known Issues ------------ - Only detects closed docstring if it is on a line of the same indentation, and has no text in front of it. Single Line docstrings are converted to block +- The tests run in python `3.4.3`, however sublime's python version is `3.3.6`. This is due to the difficulty of getting a working version of 3.3.6 in a dev environment, and the differences should be minimal. Roadmap @@ -88,6 +121,9 @@ Roadmap Things I want to do wtih this project. Not necessarily an exhaustive or prioritized list. - Unit Tests! + - Needs a test harness of some sort for sublime internals. +- CI, probably circleci +- Coverage reporting - More completions! - Javadoc style formatter - Keyboard Shortcuts