materials icon indicating copy to clipboard operation
materials copied to clipboard

TDD Hashtag table - TypeError in 01_define_a_custom_hashtable_class

Open EmersonSchindex opened this issue 2 years ago • 1 comments

source: hashtable.py in 01_define_a_custom_hashtable_class

Describe the bug running the test throws an error for line self.values = capacity * [None] TypeError: cant multiply sequence by non-int of type ' NoneType'

That's a pity, because I really like this TDD cource!

Running on Windows 10 with python version 3.7.3

EmersonSchindex avatar Mar 21 '22 11:03 EmersonSchindex

@EmersonSchindex There's not enough information in this issue description to reproduce the problem. However, the error message indicates that the HashTable class must have been instantiated with an unexpected None passed as an argument:

>>> HashTable(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in __init__
TypeError: can't multiply sequence by non-int of type 'NoneType'

All the implemented tests pass on Python 3.7.3 upon cloning the repository:

$ git clone [email protected]:realpython/materials.git
$ cd materials/hashtable/
$ pyenv local 3.7.3
$ python -m venv venv
$ source venv/bin/activate
(venv) $ python -m pip install -r requirements.txt
(venv) $ pytest 01_hashtable_prototype/01_define_a_custom_hashtable_class/
============================= test session starts =============================
platform linux -- Python 3.7.3, pytest-7.0.1, pluggy-1.0.0
rootdir: /home/realpython/materials/hashtable
plugins: unordered-0.4.1
collected 3 items                                                             

01_hashtable_prototype/01_define_a_custom_hashtable_class/test_hashtable.py ...                                                                      [100%]

============================== 3 passed in 0.01s ==============================

How did you arrive at this error?

bzaczynski avatar Aug 23 '22 18:08 bzaczynski