Beispiel #1
0
def test_filename():
    m1 = Modification('/Users/dspadini/pydriller/myfile.py', "/Users/dspadini/pydriller/mynewfile.py", ModificationType.ADD, [], '')
    m3 = Modification('/Users/dspadini/pydriller/myfile.py', "/Users/dspadini/pydriller/mynewfile.py",
                      ModificationType.ADD, [], '')
    m2 = Modification('/Users/dspadini/pydriller/myfile.py', None,
                      ModificationType.ADD, [], '')

    assert m1.filename == 'mynewfile.py'
    assert m2.filename == 'myfile.py'
    assert m1 != m2
    assert m1 == m3
Beispiel #2
0
def test_filename():
    diff_and_sc = {'diff': '', 'source_code': '', 'source_code_before': ''}
    m1 = Modification('dspadini/pydriller/myfile.py',
                      'dspadini/pydriller/mynewfile.py', ModificationType.ADD,
                      diff_and_sc)
    m3 = Modification('dspadini/pydriller/myfile.py',
                      'dspadini/pydriller/mynewfile.py', ModificationType.ADD,
                      diff_and_sc)
    m2 = Modification('dspadini/pydriller/myfile.py', None,
                      ModificationType.ADD, diff_and_sc)

    assert m1.filename == 'mynewfile.py'
    assert m2.filename == 'myfile.py'
    assert m1 != m2
    assert m3 == m1
def test_metrics_not_supported_file():
    sc = 'asd !&%@*&^@\n jjdkj'

    diff_and_sc = {'diff': '', 'source_code': sc, 'source_code_before': sc}

    m1 = Modification('test-repos/lizard/NotSupported.pdf',
                      "test-repos/lizard/NotSupported.pdf",
                      ModificationType.MODIFY, diff_and_sc)

    assert m1.nloc is None
Beispiel #4
0
def test_metrics_not_supported_file():
    sc = 'asd !&%@*&^@\n jjdkj'

    diff_and_sc = {'diff': '', 'source_code': sc}

    m1 = Modification('test-repos/test6/NotSupported.pdf',
                      "test-repos/test6/NotSupported.pdf",
                      ModificationType.MODIFY, diff_and_sc)

    assert m1.nloc == 2
    assert len(m1.methods) == 0
Beispiel #5
0
def test_metrics_java():
    with open('test-repos/test6/FileJava.java') as f:
        sc = f.read()

    diff_and_sc = {'diff': '', 'source_code': sc, 'source_code_before': sc}

    m1 = Modification('test-repos/test6/FileJava.java',
                      "test-repos/test6/FileJava.java",
                      ModificationType.MODIFY, diff_and_sc)

    assert m1.nloc == 466
    assert m1.token_count == 3809
    assert m1.complexity == 92

    assert len(m1.methods) == 46
Beispiel #6
0
def test_metrics_cpp():
    with open('test-repos/test6/FileCPP.cpp') as f:
        sc = f.read()

    diff_and_sc = {'diff': '', 'source_code': sc, 'source_code_before': sc}

    m1 = Modification('test-repos/test6/FileCPP.cpp',
                      "test-repos/test6/FileCPP.cpp", ModificationType.MODIFY,
                      diff_and_sc)

    assert m1.nloc == 793
    assert m1.token_count == 5564
    assert m1.complexity == 199

    assert len(m1.methods) == 16
Beispiel #7
0
def test_metrics_python():
    with open('test-repos/test6/git_repository.py') as f:
        sc = f.read()

    diff_and_sc = {'diff': '', 'source_code': sc, 'source_code_before': sc}

    m1 = Modification('test-repos/test6/git_repository.py',
                      "test-repos/test6/git_repository.py",
                      ModificationType.MODIFY, diff_and_sc)

    assert m1.nloc == 196
    assert m1.token_count == 1009
    assert m1.complexity == 43

    assert len(m1.methods) == 19
Beispiel #8
0
def test_metrics_java():
    with open('test-repos/test6/FileJava.java') as f:
        sc = f.read()

    diff_and_sc = {'diff': '', 'source_code': sc}

    m1 = Modification('test-repos/test6/FileJava.java',
                      "test-repos/test6/FileJava.java",
                      ModificationType.MODIFY, diff_and_sc)

    assert 466 == m1.nloc
    assert 3809 == m1.token_count
    assert 92 == m1.complexity

    assert 46 == len(m1.methods)
Beispiel #9
0
def test_metrics_cpp():
    with open('test-repos/test6/FileCPP.cpp') as f:
        sc = f.read()

    diff_and_sc = {'diff': '', 'source_code': sc}

    m1 = Modification('test-repos/test6/FileCPP.cpp',
                      "test-repos/test6/FileCPP.cpp", ModificationType.MODIFY,
                      diff_and_sc)

    assert 332 == m1.nloc
    assert 2511 == m1.token_count
    assert 83 == m1.complexity

    assert 23 == len(m1.methods)
Beispiel #10
0
def test_metrics_python():
    with open('test-repos/test6/git_repository.py') as f:
        sc = f.read()

    diff_and_sc = {'diff': '', 'source_code': sc}

    m1 = Modification('test-repos/test6/git_repository.py',
                      "test-repos/test6/git_repository.py",
                      ModificationType.MODIFY, diff_and_sc)

    assert 196 == m1.nloc
    assert 1009 == m1.token_count
    assert 43 == m1.complexity

    assert 19 == len(m1.methods)