Skip to content

Commit 4de5c73

Browse files
committed
Add i76_testcase_subclass/
1 parent b51378c commit 4de5c73

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

python_test_example/i76_testcase_subclass/__init__.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def concat(str1: str, str2: str) -> str:
2+
if not isinstance(str1, str) and isinstance(str2, str):
3+
raise TypeError
4+
5+
return str1 + str2
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from unittest import TestCase, main
2+
3+
from i76_testcase_subclass.utils import concat
4+
5+
class UtilsTestCase(TestCase):
6+
def test_good_for_concat(self):
7+
test_cases = [
8+
(('a', 'b'), 'ab'),
9+
(('test', 'case'), 'testcase'),
10+
]
11+
for value, expected in test_cases:
12+
with self.subTest(value):
13+
self.assertEqual(expected, concat(value[0], value[1]))
14+
15+
def test_bad_for_concat(self):
16+
test_cases = [
17+
(('a', 2), TypeError),
18+
((1, 'b'), TypeError),
19+
]
20+
for value, exception in test_cases:
21+
with self.subTest(value):
22+
with self.assertRaises(exception):
23+
concat(value[0], value[1])
24+
25+
if __name__ == '__main__':
26+
main()

0 commit comments

Comments
 (0)