datawithsuman commited on
Commit
72f7c6f
·
verified ·
1 Parent(s): 38ff6d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -213,7 +213,7 @@ class TestCaseGenerator:
213
 
214
  def setup_streamlit_ui(self):
215
  st.title("Auto Test Case Generation using LLM")
216
- uploaded_files = st.file_uploader("Upload a python or Java file", type=[".py", "java"], accept_multiple_files=True)
217
  if uploaded_files:
218
  for uploaded_file in uploaded_files:
219
  self.process_uploaded_file(uploaded_file)
@@ -223,11 +223,11 @@ class TestCaseGenerator:
223
  f.write(uploaded_file.getbuffer())
224
  st.success("File uploaded...")
225
  _, file_extension = os.path.splitext(uploaded_file.name)
226
- print(file_extension)
227
  st.success("Fetching list of functions...")
228
  file_path = f"./data/{uploaded_file.name}"
229
  self.extract_functions_from_file(file_path, file_extension)
230
  st.write(self.list_of_functions)
 
231
 
232
  def extract_functions_from_file(self, file_path, file_extension):
233
  if file_extension == '.py':
@@ -294,16 +294,12 @@ class TestCaseGenerator:
294
  return
295
 
296
  snippet = self.functions[func]
297
- _ , file_extension = os.path.splitext(uploaded_file.name)
298
- lang = file_extension[1:]
299
 
300
  prompt = f"""1. You will be provided with the following inputs:
301
  <function_code>
302
  {snippet}
303
  </function_code>
304
 
305
- <language>{lang}</language>
306
-
307
  2. Analyze the provided function:
308
  - Identify the function name, parameters, and return type
309
  - Determine the main logic and branches in the function
@@ -355,6 +351,7 @@ class TestCaseGenerator:
355
 
356
  def run(self):
357
  self.setup_streamlit_ui()
 
358
  if "messages" not in st.session_state:
359
  st.session_state.messages = []
360
 
 
213
 
214
  def setup_streamlit_ui(self):
215
  st.title("Auto Test Case Generation using LLM")
216
+ uploaded_files = st.file_uploader("Upload a python or Java file", type=["py", "java"], accept_multiple_files=True)
217
  if uploaded_files:
218
  for uploaded_file in uploaded_files:
219
  self.process_uploaded_file(uploaded_file)
 
223
  f.write(uploaded_file.getbuffer())
224
  st.success("File uploaded...")
225
  _, file_extension = os.path.splitext(uploaded_file.name)
 
226
  st.success("Fetching list of functions...")
227
  file_path = f"./data/{uploaded_file.name}"
228
  self.extract_functions_from_file(file_path, file_extension)
229
  st.write(self.list_of_functions)
230
+
231
 
232
  def extract_functions_from_file(self, file_path, file_extension):
233
  if file_extension == '.py':
 
294
  return
295
 
296
  snippet = self.functions[func]
 
 
297
 
298
  prompt = f"""1. You will be provided with the following inputs:
299
  <function_code>
300
  {snippet}
301
  </function_code>
302
 
 
 
303
  2. Analyze the provided function:
304
  - Identify the function name, parameters, and return type
305
  - Determine the main logic and branches in the function
 
351
 
352
  def run(self):
353
  self.setup_streamlit_ui()
354
+
355
  if "messages" not in st.session_state:
356
  st.session_state.messages = []
357