aider/benchmark/tests/test_benchmark.py
Paul Gauthier 51638d0989 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.
2023-06-28 15:37:41 -07:00

14 lines
480 B
Python

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)