|
1 | | -import pytest |
2 | | -import os |
3 | | -from spice.analyzers.count_comment_lines import count_comment_lines |
| 1 | +# import pytest |
| 2 | +# import os |
| 3 | +# from spice.analyzers.count_comment_lines import count_comment_lines |
4 | 4 |
|
5 | | -# Define the path to the sample code directory relative to the test file |
6 | | -SAMPLE_CODE_DIR = os.path.join(os.path.dirname(__file__), "..", "..", "sample-code") |
| 5 | +# # Define the path to the sample code directory relative to the test file |
| 6 | +# SAMPLE_CODE_DIR = os.path.join(os.path.dirname(__file__), "..", "..", "sample-code") |
7 | 7 |
|
8 | | -# Test cases for count_comment_lines |
9 | | -@pytest.mark.parametrize( |
10 | | - "filename, expected_comment_lines", |
11 | | - [ |
12 | | - ("sample_comments.py", 4), # Based on the content of sample_comments.py |
13 | | - ("example.py", 1), # Based on the content of example.py (assuming it has one full comment line) |
14 | | - ("example.js", 2), # Based on the content of example.js (assuming two full comment lines) |
15 | | - ("example.go", 2), # Based on the content of example.go (assuming two full comment lines) |
16 | | - ("example.rb", 1), # Based on the content of example.rb (assuming one full comment line) |
17 | | - ] |
18 | | -) |
19 | | -def test_count_comment_lines_python(filename, expected_comment_lines): |
20 | | - """Test count_comment_lines with various sample files.""" |
21 | | - file_path = os.path.join(SAMPLE_CODE_DIR, filename) |
22 | | - # Ensure the sample file exists before running the test |
23 | | - assert os.path.exists(file_path), f"Sample file not found: {file_path}" |
24 | | - assert count_comment_lines(file_path) == expected_comment_lines |
| 8 | +# # Test cases for count_comment_lines |
| 9 | +# @pytest.mark.parametrize( |
| 10 | +# "filename, expected_comment_lines", |
| 11 | +# [ |
| 12 | +# ("sample_comments.py", 4), # Based on the content of sample_comments.py |
| 13 | +# ("example.py", 1), # Based on the content of example.py (assuming it has one full comment line) |
| 14 | +# ("example.js", 2), # Based on the content of example.js (assuming two full comment lines) |
| 15 | +# ("example.go", 2), # Based on the content of example.go (assuming two full comment lines) |
| 16 | +# ("example.rb", 1), # Based on the content of example.rb (assuming one full comment line) |
| 17 | +# ] |
| 18 | +# ) |
| 19 | +# def test_count_comment_lines_python(filename, expected_comment_lines): |
| 20 | +# """Test count_comment_lines with various sample files.""" |
| 21 | +# file_path = os.path.join(SAMPLE_CODE_DIR, filename) |
| 22 | +# # Ensure the sample file exists before running the test |
| 23 | +# assert os.path.exists(file_path), f"Sample file not found: {file_path}" |
| 24 | +# assert count_comment_lines(file_path) == expected_comment_lines |
25 | 25 |
|
26 | | -def test_count_comment_lines_empty_file(): |
27 | | - """Test count_comment_lines with an empty file.""" |
28 | | - empty_file_path = os.path.join(SAMPLE_CODE_DIR, "empty_test_file.py") |
29 | | - with open(empty_file_path, "w") as f: |
30 | | - f.write("") |
31 | | - assert count_comment_lines(empty_file_path) == 0 |
32 | | - os.remove(empty_file_path) # Clean up the empty file |
| 26 | +# def test_count_comment_lines_empty_file(): |
| 27 | +# """Test count_comment_lines with an empty file.""" |
| 28 | +# empty_file_path = os.path.join(SAMPLE_CODE_DIR, "empty_test_file.py") |
| 29 | +# with open(empty_file_path, "w") as f: |
| 30 | +# f.write("") |
| 31 | +# assert count_comment_lines(empty_file_path) == 0 |
| 32 | +# os.remove(empty_file_path) # Clean up the empty file |
33 | 33 |
|
34 | | -def test_count_comment_lines_no_comments(): |
35 | | - """Test count_comment_lines with a file containing no comments.""" |
36 | | - no_comments_path = os.path.join(SAMPLE_CODE_DIR, "no_comments_test_file.py") |
37 | | - with open(no_comments_path, "w") as f: |
38 | | - f.write("print(\"Hello\")\nx = 1") |
39 | | - assert count_comment_lines(no_comments_path) == 0 |
40 | | - os.remove(no_comments_path) # Clean up |
| 34 | +# def test_count_comment_lines_no_comments(): |
| 35 | +# """Test count_comment_lines with a file containing no comments.""" |
| 36 | +# no_comments_path = os.path.join(SAMPLE_CODE_DIR, "no_comments_test_file.py") |
| 37 | +# with open(no_comments_path, "w") as f: |
| 38 | +# f.write("print(\"Hello\")\nx = 1") |
| 39 | +# assert count_comment_lines(no_comments_path) == 0 |
| 40 | +# os.remove(no_comments_path) # Clean up |
41 | 41 |
|
42 | | -def test_count_comment_lines_only_inline(): |
43 | | - """Test count_comment_lines with only inline comments.""" |
44 | | - inline_comments_path = os.path.join(SAMPLE_CODE_DIR, "inline_comments_test_file.py") |
45 | | - with open(inline_comments_path, "w") as f: |
46 | | - f.write("x = 1 # inline\ny = 2 # another inline") |
47 | | - assert count_comment_lines(inline_comments_path) == 0 |
48 | | - os.remove(inline_comments_path) # Clean up |
| 42 | +# def test_count_comment_lines_only_inline(): |
| 43 | +# """Test count_comment_lines with only inline comments.""" |
| 44 | +# inline_comments_path = os.path.join(SAMPLE_CODE_DIR, "inline_comments_test_file.py") |
| 45 | +# with open(inline_comments_path, "w") as f: |
| 46 | +# f.write("x = 1 # inline\ny = 2 # another inline") |
| 47 | +# assert count_comment_lines(inline_comments_path) == 0 |
| 48 | +# os.remove(inline_comments_path) # Clean up |
49 | 49 |
|
50 | 50 |
|
0 commit comments