mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 09:44:59 +00:00
aider: Added test for cleanup_test_output
function in test_benchmark.py
.
# Context: USER: make a test for `cleanup_test_output` ASSISTANT: To create a test for the `cleanup_test_output` function, we need to create a new test file in the `benchmark/tests` directory. Let's call it `test_benchmark_utils.py`. In this new file, we will import the `cleanup_test_output` function from `benchmark.py` and write a test function using the `unittest` framework. Here is the content for the new test file: ```python benchmark/tests/test_benchmark_utils.py <<<<<<< ORIGINAL ======= import unittest from benchmark.benchmark import cleanup_test_output class TestCleanupTestOutput(unittest.TestCase): def test_cleanup_test_output(self): # Test case with timing info output = "Ran 5 tests in 0.003s\nOK" expected = "\nOK" self.assertEqual(cleanup_test_output(output), expected) # Test case without timing info output = "OK" expected = "OK" self.assertEqual ^C KeyboardInterrupt USER: no in test_benchmark.py ASSISTANT: To add a test for the `cleanup_test_output` function in the `test_benchmark.py` file, we need to import the `cleanup_test_output` function from `benchmark.py` and write a test function using the `unittest` framework. Here is the content for the updated test file: ```python benchmark/tests/test_benchmark.py <<<<<<< ORIGINAL ======= import unittest from benchmark.benchmark import cleanup_test_output class TestCleanupTestOutput(unittest.TestCase): def test_cleanup_test_output(self): # Test case with timing info output = "Ran 5 tests in 0.003s\nOK" expected = "\nOK" self.assertEqual(cleanup_test_output(output), expected) # Test case without timing info output = "OK" expected = "OK" self.assertEqual(cleanup_test_output(output), expected) >>>>>>> UPDATED ``` Please note that you need to add the above code to the existing `test_benchmark.py` file. The `ORIGINAL` section is empty because it's a new addition to the file.
This commit is contained in:
parent
ac72e4c426
commit
51638d0989
1 changed files with 14 additions and 0 deletions
|
@ -0,0 +1,14 @@
|
|||
import unittest
|
||||
from benchmark.benchmark import cleanup_test_output
|
||||
|
||||
class TestCleanupTestOutput(unittest.TestCase):
|
||||
def test_cleanup_test_output(self):
|
||||
# Test case with timing info
|
||||
output = "Ran 5 tests in 0.003s\nOK"
|
||||
expected = "\nOK"
|
||||
self.assertEqual(cleanup_test_output(output), expected)
|
||||
|
||||
# Test case without timing info
|
||||
output = "OK"
|
||||
expected = "OK"
|
||||
self.assertEqual(cleanup_test_output(output), expected)
|
Loading…
Add table
Add a link
Reference in a new issue