def test_restricted_filename(assert_errors, filename, default_options):
    """Testing that some file names are restricted."""
    visitor = WrongModuleNameVisitor(default_options,
                                     filename=filename + '.py')
    visitor.run()

    assert_errors(visitor, [WrongModuleNameViolation])
Exemplo n.º 2
0
def test_too_long_filename(assert_errors, filename, default_options):
    """Testing that long file names are restricted."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [
        TooLongNameViolation,
    ])
def test_too_short_filename(assert_errors, filename, default_options):
    """Testing that short file names are restricted."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [
        TooShortNameViolation,
        WrongModuleNamePatternViolation,
    ])
Exemplo n.º 4
0
def test_corner_case(assert_errors, filename, default_options):
    """Testing corner case related to underscore name patterns."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [
        WrongModuleNamePatternViolation,
        UnderscoredNumberNameViolation,
    ])
def test_length_option(assert_errors, assert_error_text, options):
    """Ensures that option `--min-name-length` works."""
    filename = 'test.py'
    option_values = options(min_name_length=5)
    visitor = WrongModuleNameVisitor(option_values, filename=filename)
    visitor.run()

    assert_errors(visitor, [TooShortNameViolation])
    assert_error_text(visitor, filename.replace('.py', ''))
def test_filename_without_underscored_number(
    assert_errors,
    filename,
    default_options,
):
    """Testing that file names with underscored numbers are restricted."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [])
Exemplo n.º 7
0
def test_wrong_filename(
    assert_errors,
    filename,
    default_options,
):
    """Testing that incorrect names are restricted."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [WrongModuleNamePatternViolation])
def test_max_length_option(assert_errors, assert_error_text, options):
    """Ensures that option `--max-name-length` works."""
    max_length = 55
    filename = 'very_long_name_that_should_not_pass_unless_changed_shorter.py'
    option_values = options(max_name_length=max_length)
    visitor = WrongModuleNameVisitor(option_values, filename=filename)
    visitor.run()

    assert_errors(visitor, [TooLongNameViolation])
    assert_error_text(visitor, filename.replace('.py', ''))
def test_underscore_filename(
    assert_errors,
    assert_error_text,
    filename,
    default_options,
):
    """Ensures incorrect underscores are caught."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [ConsecutiveUnderscoresInNameViolation])
    assert_error_text(visitor, filename.replace('.py', ''))
def test_private_filename(
    assert_errors,
    assert_error_text,
    filename,
    default_options,
):
    """Ensures that names with private names are caught."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [PrivateNameViolation])
    assert_error_text(visitor, filename.replace('.py', ''))
Exemplo n.º 11
0
def test_filename_with_underscored_number(
    assert_errors,
    assert_error_text,
    filename,
    default_options,
):
    """Testing that file names with underscored numbers are restricted."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [UnderscoredNumberNameViolation])
    assert_error_text(visitor, filename.replace('.py', ''))
Exemplo n.º 12
0
def test_simple_filename(assert_errors, filename, default_options):
    """Testing that simple file names works well."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [])
Exemplo n.º 13
0
def test_normal_module_name(assert_errors, filename, default_options):
    """Testing that short file names are restricted."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [])
def test_correct_filename(assert_errors, filename, default_options):
    """Testing that correct file names are allowed."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [])
Exemplo n.º 15
0
def test_readable_filename(assert_errors, filename, default_options):
    """Testing that ordinary naming works well."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [])
Exemplo n.º 16
0
def test_unreadable_filename(assert_errors, filename, default_options):
    """Testing that unreadable characters combinations do not allowed."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [UnreadableNameViolation])
Exemplo n.º 17
0
def test_correct_magic_filename(assert_errors, filename, default_options):
    """Testing that allowed magic file names works well."""
    visitor = WrongModuleNameVisitor(default_options, filename=filename)
    visitor.run()

    assert_errors(visitor, [])