pr3/python/unittests/unittests.ipynb

35 lines
718 B
Plaintext
Raw Permalink Normal View History

2023-06-23 23:05:46 +02:00
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Unit-Test\n",
"\n",
"import unittest\n",
"\n",
"def is_palindrome(s : str):\n",
" return s == s[::-1]\n",
"\n",
"class KnownInput(unittest.TestCase):\n",
" knownValues = (('lego', False), ('radar', True))\n",
"\n",
" def testKnownValues(self):\n",
" for word, palin in self.knownValues:\n",
" result = is_palindrome(word)\n",
" self.assertEqual(result, palin)"
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}