realpython / materials

Bonus materials, exercises, and example projects for our Python tutorials
https://realpython.com
MIT License
4.77k stars 5.3k forks source link

TDD Hashtag table - TypeError in 01_define_a_custom_hashtable_class #253

Open EmersonSchindex opened 2 years ago

EmersonSchindex commented 2 years ago

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

bzaczynski commented 2 years ago

@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 git@github.com: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?