mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-14 21:38:02 +00:00
Update tree check balance challenge (#120)
Use more specific exception types.
This commit is contained in:
@@ -120,7 +120,7 @@
|
||||
"\n",
|
||||
" def check_balance(self):\n",
|
||||
" if self.root is None:\n",
|
||||
" raise Exception('No root node')\n",
|
||||
" raise TypeError('root cannot be None')\n",
|
||||
" height = self._check_height(self.root)\n",
|
||||
" return height != -1"
|
||||
]
|
||||
@@ -155,7 +155,7 @@
|
||||
"\n",
|
||||
"class TestCheckBalance(object):\n",
|
||||
"\n",
|
||||
" @raises(Exception)\n",
|
||||
" @raises(TypeError)\n",
|
||||
" def test_check_balance_empty(self):\n",
|
||||
" bst = BstBalance(None)\n",
|
||||
" bst.check_balance()\n",
|
||||
|
||||
Reference in New Issue
Block a user