Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Completing Your Stack Class & Measuring Test Coverage

Give Feedback

In this lesson you’ll complete your Stack class by implementing the pop method, which includes writing tests for it.

Comments & Discussion

ypochienTW on March 13, 2019

Simply and clear. Nice course for pytest newbie.

Chris on March 15, 2019

I may have missed it somewhere in the course, but the cov plugin was not installed by default on my windows machine while working in venv. I had to do a little googling to solve the error I received:

Hope this helps someone in the future.

Rodrigo Vieira on March 17, 2019

Yes, definitively the “coverage” plugin is missing. We can simply install that by running:

pip install pytest-cov

Also, I don’t know why but all my “site-packages” files are getting returned by python -m pytest --cov. Does anyone know how to return only my project files as it’s returned on video lesson?

Isaac Dadzie on March 20, 2019

You can run the command.

python -m pytest -v --cov=ds

OR Create a .coveragerc file with following

source = ds

Your directory structure should look like this.

-rw-r--r-- 1 user user   17 Mar 20 12:14 .coveragerc
drwxr-xr-x 3 user user 4.0K Mar 20 11:25 ds/
drwxr-xr-x 3 user user 4.0K Mar 20 11:37 tests/

Martin Breuss RP Team on July 17, 2019

Nice! Thanks @Chris, @Rodrigo Vieira and @Isaac Dadzie for filling in the last missing pieces and pointing us forward here :)

Lokman on Feb. 19, 2020

Hello, why class constructor in push function don’t have return keyword like the others?

def push(self, item):

Ricky White RP Team on Feb. 21, 2020

Hi @Lokman,

Functions don’t aways have to return something. In this case, the push function only appends an item to _storage. We don’t need to have it tell us anything once it’s done. Unlike def __len__() where we want to know what the length is. Hence this returns the length of the current Stack to us.

Hope that helps.

Lokman on Feb. 23, 2020

Thanks @Ricky White for the answer.

Become a Member to join the conversation.