Skip to content

Commit 35b9642

Browse files
committed
Add test
1 parent 43d969a commit 35b9642

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

tests/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import io
2+
import contextlib
3+
from unittest import TestCase
4+
5+
class BaseTestCase(TestCase):
6+
def assertStdout(self, expected_output, func):
7+
with io.StringIO() as buf, contextlib.redirect_stdout(buf):
8+
func()
9+
output = buf.getvalue().strip()
10+
self.assertEqual(output, expected_output)
11+
File renamed without changes.

tests/test_hello_world.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .base import BaseTestCase
2+
3+
class TestHelloWorld(BaseTestCase):
4+
def test_hello_world(self):
5+
def hello_world():
6+
from . import hello_world
7+
self.assertStdout('Hello, World!', hello_world)

0 commit comments

Comments
 (0)