# tests.test_compliance

import nose.tools as nose
import glob
import os.path
import json
import jsonschema
import pep8


def test_pep8():
    file_paths = glob.iglob('*/*.py')
    for file_path in file_paths:
        style_guide = pep8.StyleGuide(quiet=True)
        total_errors = style_guide.input_file(file_path)
        test_pep8.__doc__ = '{} should comply with PEP 8'.format(file_path)
        fail_msg = '{} does not comply with PEP 8'.format(file_path)
        yield nose.assert_equal, total_errors, 0, fail_msg


def test_json():
    schemas = {
        'schema-languages': 'yvs/data/languages.json',
        'schema-defaults': 'yvs/data/defaults.json',
        'schema-chapters': 'yvs/data/bible/chapters.json',
        'schema-bible': 'yvs/data/bible/language-*.json'
    }
    for schema_name, data_path_pattern in schemas.iteritems():
        schema_path = 'yvs/data/schema/{}.json'.format(schema_name)
        with open(schema_path) as schema_file:
            schema = json.load(schema_file)
        data_paths = glob.iglob(data_path_pattern)
        for data_path in data_paths:
            with open(data_path) as data_file:
                data = json.load(data_file)
            test_json.__doc__ = '{} should comply with schema'.format(
                os.path.relpath(data_path, 'yvs/data'))
            validator = jsonschema.validate(data, schema)
            yield nose.assert_is_none, validator

@@ -60,23 +60,8 @@
 lob%0A
-import os.path%0A
 impo
@@ -93,20 +93,68 @@
 %0Aimport 
-pep8
+os.path%0Aimport pep8%0Aimport radon.complexity as radon
 %0A%0A%0Adef t
@@ -549,16 +549,575 @@
 l_msg%0A%0A%0A
+def test_complexity():%0A    file_paths = glob.iglob('*/*.py')%0A    for file_path in file_paths:%0A        with open(file_path, 'r') as file:%0A            blocks = radon.cc_visit(file.read())%0A            for block in blocks:%0A                test_desc = '%7B%7D should have a low cyclomatic complexity score'%0A                test_complexity.__doc__ = test_desc.format(file_path)%0A                fail_msg = '%7B%7D has a complexity of %7B%7D'.format(%0A                    file_path, block.complexity)%0A                yield nose.assert_less_equal, block.complexity, 10, fail_msg%0A%0A%0A
 def test

Test cyclomatic complexity of all functions