Files
nlprog/tests/test_project_profile.py
2026-06-17 20:41:49 +08:00

30 lines
1.1 KiB
Python

import tempfile
import unittest
from pathlib import Path
from nlprog.project_profile import infer_project, init_project, load_project_profile
class ProjectProfileTests(unittest.TestCase):
def test_infers_python_project(self):
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "pyproject.toml").write_text("[project]\nname='x'\n", encoding="utf-8")
(root / "src").mkdir()
profile = infer_project(root)
self.assertIn("python", profile.project_types)
self.assertIn("python -m compileall src", profile.verification_commands)
def test_init_project_writes_profile_files(self):
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "pyproject.toml").write_text("[project]\nname='x'\n", encoding="utf-8")
created = init_project(root)
self.assertEqual(len(created), 3)
profile = load_project_profile(root)
self.assertIn("pyproject.toml", profile.important_files)
if __name__ == "__main__":
unittest.main()