Get startedGet started for free

Writing some basic tests

If you have written a full suite of tests for your code, it means you can develop and modify it more freely. If you make some changes that break your code, you'll be able to find this out right away. It also signals to users that your code is more likely to be error free, and can be trusted to do its job.

The tests you write will check that your functions give the expected outputs for given inputs. In this case you will be writing numeric tests to make sure that the correct answer is returned when converting a number of inches to feet and vice versa.

In this exercise, you'll write a test for one of your functions inside impyrial.

This exercise is part of the course

Developing Python Packages

View Course

Exercise instructions

  • Define a function which takes no arguments to test the inches_to_feet() function.
  • Inside the test function, check that 12 inches is converted to 1.0 feet.
  • Check that 2.5 feet is converted to 30.0 inches when using option reverse=True in inches_to_feet().

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise