예제 #1
0
def main():
    args = parse_args()
    config_path = args.config_path or os.path.join(args.path, 'setup.cfg')
    updated_config = extract_fiasko_config_from_cfg_file(config_path)
    violations = validate(args.path, **updated_config)
    for violation_slug, violation_message in violations:
        print('%-40s\t%s' % (violation_slug, violation_message))
    print('=' * 50)
    print('Total %s violations' % len(violations))
예제 #2
0
def test_warnings_show_up_after_fail(file_3_spaces_repo_path):
    expected_output = [('too_many_pep8_violations', '43 PEP8 violations'),
                       ('indent_not_multiple_of_tab_size',
                        'file_3_spaces.py:16')]
    output = validate(file_3_spaces_repo_path)
    assert output == expected_output
def test_validator_with_two_disjunct_tokens_fail(origin_repo,
                                                 error_validator_groups):
    output = validate(origin_repo,
                      validator_tokens=['sql', 'concurrency'],
                      error_validator_groups=error_validator_groups)
    assert ('tokenized_validator_with_two_disjunct_tokens', '') not in output
def test_validator_with_two_conjunct_tokens_ok(origin_repo,
                                               error_validator_groups):
    output = validate(origin_repo,
                      validator_tokens=('twisted', 'django'),
                      error_validator_groups=error_validator_groups)
    assert ('tokenized_validator_with_two_conjuct_tokens', '') in output
def test_tokenized_validator_with_single_token_fail(origin_repo,
                                                    error_validator_groups):
    output = validate(origin_repo,
                      validator_token=None,
                      error_validator_groups=error_validator_groups)
    assert ('tokenized_validator_with_single_token', '') not in output
def test_validator_with_two_disjunct_tokens_ok(origin_repo,
                                               error_validator_groups):
    output = validate(origin_repo,
                      validator_tokens=['minmax', 'sql'],
                      error_validator_groups=error_validator_groups)
    assert ('tokenized_validator_with_two_disjunct_tokens', '') in output
def test_tokenized_validator_with_single_token_ok(origin_repo,
                                                  error_validator_groups):
    output = validate(origin_repo,
                      validator_token=1,
                      error_validator_groups=error_validator_groups)
    assert ('tokenized_validator_with_single_token', '') in output
def test_mark_repo_with_both_fail(origin_repo):
    token = 'django'
    tokens = ('djano', 'celery')
    with pytest.raises(ValueError):
        validate(origin_repo, validator_token=token, validator_tokens=tokens)
def test_validator_with_two_conjunct_tokens_fail(origin_repo,
                                                 error_validator_groups):
    output = validate(origin_repo,
                      validator_tokens={'django', 'tornado'},
                      error_validator_groups=error_validator_groups)
    assert ('tokenized_validator_with_two_conjuct_tokens', '') not in output
예제 #10
0
def test_syntax_error_shows_up(syntax_error_repo):
    expected_output = [
        ('syntax_error', 'file_with_syntax_error.py')
    ]
    output = validate(syntax_error_repo)
    assert output == expected_output
def test_not_existing_file_raises_correct_exception(non_existent_directory):
    with pytest.raises(FileNotFoundError):
        validate(non_existent_directory)