1. Learn
  2. /
  3. Courses
  4. /
  5. Unit Testing for Data Science in Python

Exercise

TDD: Requirement collection

What should convert_to_int() do if the arguments are not normal? In particular, there are three special argument types:

  1. Arguments that are missing a comma e.g. "178100,301".
  2. Arguments that have the comma in the wrong place e.g. "12,72,891".
  3. Float valued strings e.g. "23,816.92".

Also, should convert_to_int() raise an exception for specific argument values?

When your boss asked you to implement the function, she didn't say anything about these cases! But since you want to write tests for special and bad arguments as a part of TDD, you go and ask your boss.

She says that convert_to_int() should return None for every special argument and there are no bad arguments for this function.

pytest has been imported for you.

Instructions 1/2

undefined XP
    1
    2
  • Give a name to the test by using the standard name prefix that pytest expects followed by on_string_with_missing_comma.
  • Assign actual to the actual return value for the argument "12,72,891".
  • Complete the assert statement.