diff --git a/.ci/check_moban.sh b/.ci/check_moban.sh new file mode 100755 index 0000000..b44fa88 --- /dev/null +++ b/.ci/check_moban.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -ex + +: "${MOBAN_BRANCH:=master}" + +if [ ! -d ../coala-mobans ]; then + git clone https://gitlab.com/coala/mobans \ + --branch=${MOBAN_BRANCH} ../coala-mobans +fi + +moban +git diff --exit-code diff --git a/.moban.yaml b/.moban.yaml index e746bf7..90ab43f 100644 --- a/.moban.yaml +++ b/.moban.yaml @@ -1,4 +1,4 @@ -overrides: coala.yaml +overrides: .nocover.yaml name: coala-quickstart contact: coala.analyzer@gmail.com @@ -44,9 +44,11 @@ configuration: configuration_dir: ../coala-mobans/ targets: - setup.py: coala-setup.py.jj2 + - setup.cfg: setup.cfg.jj2 - requirements.txt: requirements.txt.jj2 - test-requirements.txt: test-requirements.txt.jj2 - coala_quickstart/VERSION: VERSION.jj2 - coala_quickstart/__init__.py: __init__.py.jj2 - .ci/appveyor.yml: ci/appveyor.yml.jj2 - .ci/run_with_env.cmd: run_with_env.cmd + - .ci/check_moban.sh: ci/check_moban.sh diff --git a/.nocover.yaml b/.nocover.yaml new file mode 100644 index 0000000..614510d --- /dev/null +++ b/.nocover.yaml @@ -0,0 +1,46 @@ +overrides: coala.yaml + +allow_generic_no_cover: true + +nocover_file_globs: + # https://github.com/coala/coala-quickstart/issues/274 + - coala_quickstart/generation/Bears.py + # https://github.com/coala/coala-quickstart/issues/273 + - coala_quickstart/generation/FileGlobs.py + - coala_quickstart/info_extractors/EditorconfigInfoExtractor.py + # https://github.com/coala/coala-quickstart/issues/222 + - coala_quickstart/info_extractors/EditorconfigParsing.py + - coala_quickstart/info_extractors/GemfileInfoExtractor.py + - coala_quickstart/info_extractors/GruntfileInfoExtractor.py + +nocover_regexes: + # coala_quickstart.py + - args.green_mode + # generation/InfoMapping.py + # https://github.com/coala/coala-quickstart/issues/275 + - INFO_SETTING_MAPS = + # generation/Project.py + # https://github.com/coala/coala-quickstart/issues/276 + - def language_percentage + # generation/Settings.py::write_coafile + # https://github.com/coala/coala-quickstart/issues/277 + - 'if os.path.isfile\(coafile\):' + # generation/SettingsFilling.py + # https://github.com/coala/coala-quickstart/issues/278 + - def autofill_value + - def is_autofill_possible + - def require_setting + # generation/Settings.py::get_extensions + # https://github.com/coala/coala-quickstart/issues/279 + - if ext in exts + # generation/SettingsClass.py::fillup_optional_settings + # https://github.com/coala/coala-quickstart/issues/280 + - if inside_annot + # generation/SettingsClass.py::BearSettings.__init__ + - if hasattr.*generate_config + # generation/Utilities.py + # https://github.com/coala/coala-quickstart/issues/281 + - def is_glob_exp + - def get_gitignore_glob + - def parse_gitignore_line + - def get_language_from_hashbang diff --git a/.travis.yml b/.travis.yml index baf6edd..037fefb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,15 +4,32 @@ python: - 3.5 - 3.6 +stages: + - test + - moban + +.disable_global: &disable_global + before_install: false + install: false + script: false + +.check_moban: &check_moban + <<: *disable_global + python: 3.6 + stage: moban + install: pip install moban + script: .ci/check_moban.sh + +jobs: + include: + - *check_moban + cache: pip: true before_install: - pip install setuptools -U - pip install -r requirements.txt -r test-requirements.txt - - git clone https://gitlab.com/coala/mobans ../coala-mobans - - moban - - git diff --exit-code script: - pytest diff --git a/coala_quickstart/generation/SettingsFilling.py b/coala_quickstart/generation/SettingsFilling.py index 59c069f..b065245 100644 --- a/coala_quickstart/generation/SettingsFilling.py +++ b/coala_quickstart/generation/SettingsFilling.py @@ -59,7 +59,7 @@ def fill_section(section, for setting in needed_settings.keys(): setting_bears = needed_settings[setting]['bears'] setting_help_text = needed_settings[setting]['help_text'] - to_fill_values = list(autofill_value_if_possible( + to_fill_values = list(autofill_value( setting, section, setting_bears, extracted_info)) if len(set(to_fill_values)) == 1: @@ -71,7 +71,7 @@ def fill_section(section, setting, setting_help_text, setting_bears, to_fill_values) satisfied_settings.append(setting) - else: + else: # pragma: no cover pass for setting in satisfied_settings: @@ -86,10 +86,7 @@ def fill_section(section, return section -def autofill_value_if_possible(setting_key, - section, - bears, - extracted_information): +def autofill_value(setting_key, section, bears, extracted_information): """ For the given setting configurations, checks if there is a possiblity of filling the value from the extracted information, @@ -121,10 +118,7 @@ def autofill_value_if_possible(setting_key, yield mapping['mapper_function'](val) -def is_autofill_possible(setting_key, - section, - bears, - extracted_info): +def is_autofill_possible(setting_key, section, bears, extracted_info): """ Checks if it is possible to autofill the setting values. """ diff --git a/coala_quickstart/generation/Utilities.py b/coala_quickstart/generation/Utilities.py index 4ffb228..8f56d96 100644 --- a/coala_quickstart/generation/Utilities.py +++ b/coala_quickstart/generation/Utilities.py @@ -97,7 +97,7 @@ def split_by_language(project_files): for lang in exts[ext]: lang_files[lang.lower()].add(file) lang_files['all'].add(file) - else: + else: # pragma: nocover with open(file, 'r') as data: hashbang = data.readline() if(re.match(HASHBANG_REGEX, hashbang)): diff --git a/coala_quickstart/info_extraction/Info.py b/coala_quickstart/info_extraction/Info.py index 3f7a990..ae138b9 100644 --- a/coala_quickstart/info_extraction/Info.py +++ b/coala_quickstart/info_extraction/Info.py @@ -21,9 +21,6 @@ def __init__(self, :param extractor: ``InfoExtractor`` instance used to extract the information. """ - if not self.value_type: - self.value_type = (object,) - assert_type_signature(value, self.value_type, 'value') self.source = source self._value = value diff --git a/coala_quickstart/info_extraction/Utilities.py b/coala_quickstart/info_extraction/Utilities.py index 8564b11..53dce3a 100644 --- a/coala_quickstart/info_extraction/Utilities.py +++ b/coala_quickstart/info_extraction/Utilities.py @@ -18,6 +18,10 @@ def assert_type_signature(value, type_signature, argname): True >>> assert_type_signature("tab", {"tab", "space"}, "var") True + >>> assert_type_signature("tab", 1, "var") + Traceback (most recent call last): + ... + TypeError: type_signature must be an Iterable or a type... :param value: Object to be validated against ``type_signature``. :param type_signature: Object that describes allowed types and values for diff --git a/setup.cfg b/setup.cfg index d092384..ae28526 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,29 +1,89 @@ +[bdist_wheel] +python-tag = py34.py35.py36 + [tool:pytest] -norecursedirs = - .git - dist - build - venv - .env +minversion = 3.6.1 + testpaths = - coala_quickstart - tests -python_files = *.py -timeout = 35 + coala_quickstart + tests + +python_files = *Test.py +python_classes = *Test + addopts = - --color=yes - --doctest-glob=*.rst - --doctest-modules - --cov=coala_quickstart - -r s -env = - PYTHONHASHSEED=0 -# PYTHONHASHSEED=0 is required to use same hashes in pytests-xdist's workers + -r a + -p no:logging + --color=yes + --doctest-glob=*.rst + --doctest-modules + --doctest-ignore-import-error + --error-for-skips + --cov + --instafail + --profile + --reorder 'requirements.txt' 'test-requirements.txt' '*' + +doctest_optionflags = + ELLIPSIS + IGNORE_EXCEPTION_DETAIL + +reqsfilenamepatterns = + requirements.txt + test-requirements.txt + +reqsignorevcs = True + +timeout = 35 + +[coverage:coverage_env_plugin] +markers = True [coverage:run] -branch=True -cover_pylib=False -source = coala_quickstart +branch = True +cover_pylib = False + +plugins = + coverage_env_plugin + coverage_config_reload_plugin + +source = + coala_quickstart + +omit = + tests/* + setup.py + coala_quickstart/__init__.py + coala_quickstart/generation/Bears.py + coala_quickstart/generation/FileGlobs.py + coala_quickstart/info_extractors/EditorconfigInfoExtractor.py + coala_quickstart/info_extractors/EditorconfigParsing.py + coala_quickstart/info_extractors/GemfileInfoExtractor.py + coala_quickstart/info_extractors/GruntfileInfoExtractor.py [coverage:report] -show_missing=True +fail_under = 100 +show_missing = True +skip_covered = False +sort = Miss +exclude_lines = + pragma: no ?cover + pragma ${PLATFORM_SYSTEM}: no cover + pragma ${OS_NAME}: no cover + pragma Python [0-9.,]*${PYTHON_VERSION}[0-9.,]*: no cover + args.green_mode + INFO_SETTING_MAPS = + def language_percentage + if os.path.isfile\(coafile\): + def autofill_value + def is_autofill_possible + def require_setting + if ext in exts + if inside_annot + if hasattr.*generate_config + def is_glob_exp + def get_gitignore_glob + def parse_gitignore_line + def get_language_from_hashbang + +[coverage:force_end_of_section] diff --git a/tests/generation/Bears.py b/tests/generation/BearsTest.py similarity index 100% rename from tests/generation/Bears.py rename to tests/generation/BearsTest.py diff --git a/tests/generation/SettingsFillingTest.py b/tests/generation/SettingsFillingTest.py index ea6bb90..b48f01b 100644 --- a/tests/generation/SettingsFillingTest.py +++ b/tests/generation/SettingsFillingTest.py @@ -80,6 +80,10 @@ def setUp(self): self.section = Section('test') self.section.append(Setting('key', 'val')) + def test_acquire_settings_error(self): + with self.assertRaises(TypeError): + acquire_settings(1, 2, 3) + def test_fill_settings(self): sections = {'test': self.section} with simulate_console_inputs() as generator: diff --git a/tests/info_extractors/UtilitiesTest.py b/tests/info_extractors/UtilitiesTest.py index 88f0681..fb1bd41 100644 --- a/tests/info_extractors/UtilitiesTest.py +++ b/tests/info_extractors/UtilitiesTest.py @@ -3,7 +3,7 @@ from coala_quickstart.info_extractors import Utilities -class UtititiesTest(unittest.TestCase): +class SearchObjectRecursivelyTest(unittest.TestCase): def setUp(self): self.simple_dict = { @@ -49,6 +49,10 @@ def setUp(self): } } + def test_type_error(self): + with self.assertRaises(TypeError): + Utilities.search_object_recursively(1, 1) + def test_search_object_recursively(self): uut = Utilities.search_object_recursively diff --git a/tests/interaction/Logo.py b/tests/interaction/LogoTest.py similarity index 100% rename from tests/interaction/Logo.py rename to tests/interaction/LogoTest.py