SXXXXXXX_PyUCC/tests/test_countings.py

35 lines
950 B
Python

import unittest
import tempfile
from pathlib import Path
from pyucc.core.countings_impl import analyze_file_counts
class TestCountings(unittest.TestCase):
def test_analyze_file_counts_basic(self):
content = """# comment line
print('hello')
# another comment
"""
with tempfile.NamedTemporaryFile("w", delete=False, suffix=".py") as tf:
tf.write(content)
tmpname = tf.name
p = Path(tmpname)
res = analyze_file_counts(p)
# Basic structure checks
self.assertIn("file", res)
self.assertIn("physical_lines", res)
self.assertIn("code_lines", res)
self.assertIn("blank_lines", res)
self.assertIn("language", res)
# Types
self.assertIsInstance(res["physical_lines"], int)
self.assertIsInstance(res["code_lines"], int)
self.assertIsInstance(res["blank_lines"], int)
if __name__ == "__main__":
unittest.main()