|  | 
| 2 | 2 | 
 | 
| 3 | 3 | ## Starting Remarks | 
| 4 | 4 | 
 | 
| 5 |  | -- [Exercise repository link](https://github.com/Simulation-Software-Engineering/testing-python-exercise-wt2223) | 
| 6 |  | -- Deadline for submitting this exercise is **Thursday 26th January 2023 09:00**. | 
| 7 |  | -- Structure all the tests in a format similar to what is shown in the [demo code](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/examples/python_testing). | 
|  | 5 | +- [Exercise repository link](https://github.com/Simulation-Software-Engineering/testing-python-exercise-wt2425) | 
|  | 6 | +- Deadline for submitting this exercise is **Wednesday 22nd January 2025 09:00**. | 
| 8 | 7 | 
 | 
| 9 | 8 | ## Prerequisites | 
| 10 | 9 | 
 | 
|  | 
| 18 | 17 |     - [pytest](https://docs.pytest.org/en/6.2.x/getting-started.html#install-pytest) | 
| 19 | 18 |     - [unittest](https://docs.python.org/3/library/unittest.html#module-unittest) | 
| 20 | 19 |     - [coverage](https://coverage.readthedocs.io/en/6.2/#quick-start) | 
| 21 |  | -    - [tox](https://tox.wiki/en/4.0.15/installation.html) | 
|  | 20 | +    - [tox](https://tox.wiki/en/4.23.2/installation.html) | 
| 22 | 21 | 
 | 
| 23 | 22 | ## Step 1 - Getting Familiar With the Code | 
| 24 | 23 | 
 | 
| 25 |  | -- Fork the [repository](https://github.com/Simulation-Software-Engineering/testing-python-exercise-wt2223). | 
|  | 24 | +- Fork the [repository](https://github.com/Simulation-Software-Engineering/testing-python-exercise-wt2425). | 
| 26 | 25 | - The code in `diffusion2d.py` is in principle the same code used for the Python packaging exercise. The main difference is that now the code has a class `SolveDiffusion2D` which has several member functions. | 
| 27 | 26 | - Each function name states what the function does, for example the function `initialize_domain()` takes in input arguments `w` (width), `h` (height), `dx` and `dy` and sets the values to member variables of the class and also calculates the number of points in x and y directions. | 
| 28 | 27 | - The functions `initialize_domain` and `initialize_physical_parameters` have default values for all input parameters, hence they can be called without any parameters. | 
|  | 
| 51 | 50 |     - Note that you have the object of the class `SolveDiffusion2D` and hence you can access member variables, for example `solver.nx` and `solver.ny`. This is useful to check the actual values. | 
| 52 | 51 | - Using a similar workflow, complete the other two unit tests. | 
| 53 | 52 | - Run the tests using `pytest`. | 
| 54 |  | -- It is observed that in some instances `pytest` is not able to find the tests. One reason is the way pytest is installed, which is typically either using `pip` or `apt`. Refer to the [corresponding section](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/python_testing_demo.md#pytest) in the demo for more details. If such errors occur, then try to explicitly point pytest to the relevant test file. For example: | 
|  | 53 | +- It is observed that in some instances `pytest` is not able to find the tests. One reason is the way pytest is installed, which is typically either using `pip` or `apt`. Refer to the [corresponding section](https://github.com/Simulation-Software-Engineering/Lecture-Material/blob/main/05_testing_and_ci/python_testing_demo.md#pytest) in the demo for more details. If such errors occur, then try to explicitly point pytest to the relevant test file in the following way: | 
| 55 | 54 | 
 | 
| 56 | 55 | ```bash | 
| 57 | 56 | pytest tests/unit/test_diffusion2d_functions.py | 
| @@ -103,9 +102,9 @@ pytest tests/unit/test_diffusion2d_functions.py | 
| 103 | 102 | 
 | 
| 104 | 103 | ## Step 7 - Automation Using tox | 
| 105 | 104 | 
 | 
| 106 |  | -- Write a `tox.ini` file such that by running the command `tox`, both `pytest` and `unittest` are executed. | 
|  | 105 | +- Write a `tox.toml` file such that by running the command `tox`, both `pytest` and `unittest` are executed. | 
| 107 | 106 | - Use the `requirements.txt` file to send all the dependencies information to tox. | 
| 108 | 107 | 
 | 
| 109 | 108 | ## Step 8 - Submission | 
| 110 | 109 | 
 | 
| 111 |  | -- Open a pull request titled `Adding tests by <GitLab username>` from your fork to the main repository. | 
|  | 110 | +- Open a pull request titled `[your GitLab username] Adding tests` from your fork to the main repository. | 
0 commit comments