Skip to content

danielbanfi47/Python_TDD_interview_public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

It is a Test-driven development (TDD) process based test.
With this the developer can create a calculator function with the following conditions:

  • It is a calculator function (with some extra sub function).
  • It allows only positive numbers (which represents integers or float), even if the numbers is in string format (in this case the decimal point must be the '.').
  • In case of valid input, it returns an integer (rounded down after the addition).
  • In case of invalid input, it throws a specific error (Value or Type) with a small comment.
  • In case of any valid string message variable given, it writes that to the stdout after a separate "The message is:" header line.
  • In case of the message contains only upper case letters, it converts that to lower case.

How to run it

You can run the tests with:
python -m pytest tests -vv

If you do not have pytest then you can install it with:
pip install pytest or python -m pip install pytest

Solution steps

In the beginning all tests are skipped except the first one, you can remove the @unittest.skip(..) decorator one by one.

So first, run only the first test case (which already enabled), which will pass.

Then remove the skip decorator from the second test case and re-run it. That will fail.
Now update the sum_of_positives(..) method to pass the test.

Repeat it with the next test cases, until the sum_of_positives(..) method passes through them all.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages