Exercise 0: Installation and self-test#

The purpose of this exercise is to install the software toolbox, set up your python development environment, and create a test handin using the code evaluation system unitgrade. I recommended that you upload your handin to DTU Learn since this will ensure you won’t have technical problems with the reports.

Complete the following steps:

Testing your code and handing in#

Solving and testing the exercises

Hint

If you are not familiar with using tests to debug you code you can look at some of my solution videos to the exercises where I try to use and talk through the test system.

This course will use a software tool called unitgrade for handing in project solutions. Unitgrade is build on top of pythons unittest framework, which is the industry-standard way of testing and verifying python code.

It is up to you if you want to use unittests to test and debug your code, or if you only want to use unitgrade to create a handin. This section will show both approaches using the fruit-homework as an example.

Solve problems and running unittests#

Why are tests so useful?

When a test fail you will know:

  • What input arguments was given to your code

  • What result your code computed

  • What the result should have been

This will give you a concrete way to attack the problem, especially if you use a debugger where you see step-by-step how your code computed the wrong result.

To run a test in VS Code, simply click on the testing flask in the left-hand side of the screen (see the video above) and run the tests you wish to run as shown in the video. In the video I try to run the tests in irlc/project0/fruit_project_tests.py.

The tests will call your functions with different input and compare their result to what it expects. In case of failure, the test will print either the error it encountered, or what output the test expected. If you open the test script, you can also see exactly how your code was called.

Creating your hand-in token-file#

Creating your hand-in

To create your hand-in, you have to use the fruit_project_grade.py-file. This file contains the same tests as you ran using the previous methods but without any risk of accidentally changing the test script.

You can run the file the same way you would run any other file in python or by using the command

python -m irlc.project0.fruit_project_grade

Either way, you will notice the script produces a file called

irlc/project0/FruitReport_handin_40_of_40.token

The numbers are the points you obtained. You should hand in this file without modifications. The file contains a copy of the source code you have written. Note the points are only indicative of how well you did on the public tests.