Skip to content

Commit 97b884b

Browse files
committed
Corrected tests removed ChatGPT from setup, using LLM instead.
1 parent c35c2d6 commit 97b884b

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
name='SummarizeGPT',
88
version='1.2',
99
packages=find_packages(),
10-
description='Tool to summarize directories of code for prompting with ChatGPT',
10+
description='Tool to summarize directories of code for prompting with LLMs',
1111
long_description=open('README.md').read(),
1212
long_description_content_type='text/markdown',
1313
author='Matt Harrison',

tests/test_summarize_gpt.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ def setUp(self):
99
self.test_file = os.path.join(self.directory, 'testfile.txt')
1010
# Create a test file with known content
1111
with open(self.test_file, 'w') as f:
12-
f.write("line1\\nline2\\nline3\\nline4\\nline5\\n")
13-
12+
for i in range(5):
13+
f.write(f'line{i+1}\n')
14+
15+
# Create a prompt file with the summary
16+
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file)
17+
prompt_file = os.path.join(self.directory, 'Context_for_ChatGPT.md')
18+
with open(prompt_file, "w", encoding="utf-8") as f:
19+
f.write(summary)
20+
1421
def tearDown(self):
1522
# Remove the test file after tests
1623
if os.path.isfile(self.test_file):
@@ -19,28 +26,25 @@ def tearDown(self):
1926
def test_gitignore(self):
2027
# Test that .gitignore is working by checking that LICENSE is not in the summary
2128
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file)
22-
self.assertNotIn('build.README.md', summary)
29+
self.assertNotIn('## ./Context_for_ChatGPT.md', summary)
2330

2431
def test_include(self):
2532
# Test include and exclude arguments
2633
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file, include_exts=['.md'])
27-
self.assertIn('python summarize_directory.py', summary)
34+
self.assertIn('python summarize_directory.py', summary) # line from readme should be included
2835

2936
def test_exclude(self):
3037
# Test exclude argument
3138
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file, exclude_exts=['.md'])
3239
self.assertNotIn('python summarize_directory.py', summary) # README.md should be excluded
33-
40+
3441
def test_max_lines(self):
35-
# Test max_lines argument
42+
# Test the max_lines argument
3643
max_lines = 3
37-
summary = summarize_directory(self.directory, max_lines=max_lines)
38-
file_summary_start = "## {}/testfile.txt\\n".format(self.directory.replace("\\\\", "/"))
39-
file_summary = "line1\\nline2\\nline3"
40-
# Check that the file summary in summary includes only max_lines lines
41-
self.assertIn(file_summary_start, summary)
42-
self.assertIn(file_summary, summary)
43-
self.assertNotIn("line4\\nline5", summary)
44+
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file, max_lines=max_lines)
45+
# Check if the 'testfile.txt' content is truncated to 'max_lines' lines
46+
self.assertNotIn('line4', summary)
47+
self.assertNotIn('line5', summary)
4448

4549
if __name__ == '__main__':
4650
unittest.main()

0 commit comments

Comments
 (0)