# Output Tests

This is an example of how you can test the output stream of student code.&#x20;

This test makes sure the student's code prints `"Hello World"`.  It assumes the student's file name is `example.py`.  Replace the import with whatever you student's file name is.&#x20;

*Note:  This code converts the output to all lowercase and removes spaces to compare against the correct value.*

#### **Grading Tests:**

```python
import unittest
import sys, io

stdout = sys.stdout

class CodingRoomsUnitTests(unittest.TestCase):

    def setUp(self):
        global stdout
        stdout = sys.stdout
        sys.stdout = io.StringIO()

    def tearDown(self):
        global stdout
        sys.stdout = stdout
        
    def test_default_case(self):
        import example
        
        output = sys.stdout.getvalue().strip("\n")

        answer = "Hello World".casefold().replace(" ", "")
        student = output.casefold().replace(" ", "")
        
        self.assertEqual(answer, student)

if __name__ == '__main__':
    unittest.main()
```

#### Sample Solution:

{% code title="example.py" %}

```python
print("Hello World")
```

{% endcode %}
