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.

Writing Your First Test & The Core TDD Cycle

Give Feedback

After setting up the project, you’ll now write your first unit test and learn about the core TDD cycle.

Comments & Discussion

Dan Bader RP Team on March 13, 2019

@Elie: Thanks for your question. Our video lessons are only available for streaming at the moment.

Elie Kawerk on March 13, 2019

Thanks @Dan, is the material covered in the video available on Github?

BTW, I like the revamped real-python platform a lot!

Dan Bader RP Team on March 13, 2019

Not right now but that’s a great idea, we can definitely put the sample code up on GitHub and then link it from here :)

Vikram Kalabi on March 18, 2019

Could you please share information on your Visual Studio theme and setup? Looks wonderful!

Dan Bader RP Team on March 18, 2019

@Vikram: Here they are—

The theme is Monokai Pro. www.monokai.pro/vscode/

I use either Dank Mono or Operator Mono. dank.sh www.typography.com/fonts/operator/styles/

I copied this from one of Chyld’s comments on another video in this series.

Grant King on March 20, 2019

That import line gives me an error with this file structure, but everything works if I move test_stack.py directly under the DS folder. Is there a better way to make it work?

Vanam on April 12, 2019

Nice tutorial, terminal that is used is it ZSH?

adoormouse on Sept. 10, 2019

Had issues with running pytest with this setup. Got it working with:

test_stack.py
from ds import Stack
...

(venv)$ python -m pytest tests/

AugustoVal on Sept. 18, 2019

Quick question - I am getting this message trying to run Pytest

AVal-iMac% python -m pytest -v
/usr/bin/python: No module named pytest
AVal-iMac% python3 -m pytest -v
/usr/local/bin/python3: No module named pytest

I have the package installed according to my list.

AVal-iMac% pip3 list           
Package            Version   
------------------ ----------
pytest             5.1.2     
pytest-cache       1.0       
pytest-pep8        1.0.6 

Any subjection why it is not working for me? I already un-installed and re-installed but is not working.

Thanking you in advances for your help

Dan Bader RP Team on Sept. 18, 2019

@AugustoVal, try running the pytest command directly like so:

pytest -v

Dri on Oct. 2, 2019

I’m getting the following error when running pytest:

ImportError while importing test module '/test-driven-dev/tests/test_stack.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_stack.py:1: in <module>
    from ds.stack import Stack
E   ModuleNotFoundError: No module named 'ds'

My directory schema:

test-driven-dev ]$ tree
.
├── ds__.py
   └── stack.py
└── tests
    ├── __pycache__
       ├── test-stack.cpython-37-pytest-5.2.0.pyc
       └── test_stack.cpython-37-pytest-5.2.0.pyc
    └── test_stack.py
   ├── __init

Any one gone through this?

przemodev on Nov. 20, 2019

I believe that saying that a single underscore makes variable private and protects from accessing the value directly does not make any sense. Would rather say that __var makes the variable somewhat private i.e: not accessible by just a . notation on the object (__var is called _ClassName__var instead and . accessible anyway).

Become a Member to join the conversation.