From 37e00ca7e3fcbdeb44dcd625ca8ebd441bcd673b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Fri, 10 Mar 2023 15:53:43 +0000 Subject: [PATCH] Fix configuration exercise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan Luis Cano Rodríguez --- swe4ds/configuration/README.md | 6 ++++++ swe4ds/configuration/{main.py => configuration.py} | 0 swe4ds/configuration/{tests.py => test_configuration.py} | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) rename swe4ds/configuration/{main.py => configuration.py} (100%) rename swe4ds/configuration/{tests.py => test_configuration.py} (74%) diff --git a/swe4ds/configuration/README.md b/swe4ds/configuration/README.md index 28dec10..c74046a 100644 --- a/swe4ds/configuration/README.md +++ b/swe4ds/configuration/README.md @@ -4,6 +4,12 @@ You were given some code that reads a set of files and applies some basic prepro **Move hardcoded paths and magic numbers to a configuration file.** +## Setup + +1. Create a new conda/mamba environment called `configuration310` with Python 3.10. +2. Activate the environment and install `pytest` on it. +3. Execute `pytest` to verify that none of the tests pass. + ## Steps 1. Observe that some absolute paths have been included in the script. Probably they worked on the author's computer, but not anymore. Move the data files to a `data/` directory, and make the paths relative. diff --git a/swe4ds/configuration/main.py b/swe4ds/configuration/configuration.py similarity index 100% rename from swe4ds/configuration/main.py rename to swe4ds/configuration/configuration.py diff --git a/swe4ds/configuration/tests.py b/swe4ds/configuration/test_configuration.py similarity index 74% rename from swe4ds/configuration/tests.py rename to swe4ds/configuration/test_configuration.py index 1073fb3..9745355 100644 --- a/swe4ds/configuration/tests.py +++ b/swe4ds/configuration/test_configuration.py @@ -1,6 +1,12 @@ import pytest -from main import load_yaml +from yaml import load, SafeLoader + + +def load_yaml(path): + with open(path) as fh: + contents = load(fh, Loader=SafeLoader) + return contents def test_shuttles_includes_adjust_factor():