Beispiel #1
0
def test_count_multiple_lines_from_contents_multiple_blanks():
    """Checks that counting lines in contents works correctly"""
    hello_contents = (
        '/* hello world */\n\nString s = new String("hello");\n//this is a comment\n\n'
    )
    count = fragments.count_lines("", "", hello_contents)
    assert count == 3
Beispiel #2
0
def test_count_single_line_from_incorrect_file(tmpdir):
    """Check that counting lines in an incorrect file works correctly."""
    hello_file = tmpdir.mkdir("subdirectory").join("Hello.java")
    assert len(tmpdir.listdir()) == 1
    directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "subdirectory"
    hello_file = "HelloWrong.java"
    count, _ = fragments.count_lines(hello_file, directory, "")
    assert count == 0
Beispiel #3
0
def test_count_single_line_from_file(tmpdir):
    """Checks that counting lines in a file works correctly"""
    hello_file = tmpdir.mkdir("subdirectory").join("Hello.java")
    hello_file.write("/* hello world */")
    assert hello_file.read() == "/* hello world */"
    assert len(tmpdir.listdir()) == 1
    directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "subdirectory"
    hello_file = "Hello.java"
    count = fragments.count_lines(hello_file, directory, "")
    assert count == 1
Beispiel #4
0
def test_count_multiple_lines_from_file(tmpdir):
    """Checks that counting lines in a file works correctly"""
    hello_file = tmpdir.mkdir("subdirectory").join("Hello.java")
    hello_file.write(
        '/* hello world */\nString s = new String("hello");\n//this is a comment'
    )
    assert len(tmpdir.listdir()) == 1
    directory = tmpdir.dirname + "/" + tmpdir.basename + "/" + "subdirectory"
    hello_file = "Hello.java"
    count = fragments.count_lines(hello_file, directory, "")
    assert count == 3
Beispiel #5
0
def test_count_single_line_from_contents():
    """Checks that counting lines in contents works correctly"""
    hello_contents = "Hello.java"
    count = fragments.count_lines("", "", hello_contents)
    assert count == 1
Beispiel #6
0
def test_count_single_line_from_empty_contents():
    """Check that counting lines in contents works correctly."""
    count, _ = fragments.count_lines("", "", "")
    assert count == 0