From 3ec5129b6e190b5187648136c06b4fc8ad8b074c Mon Sep 17 00:00:00 2001 From: Robbi Bishop-Taylor Date: Fri, 2 Aug 2024 00:25:08 +0000 Subject: [PATCH] Fix pep8 --- coastlines/validation.py | 26 ++++++++++++++------------ tests/test_coastline.py | 11 +++++------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/coastlines/validation.py b/coastlines/validation.py index 7a0e748..2706da9 100644 --- a/coastlines/validation.py +++ b/coastlines/validation.py @@ -431,9 +431,11 @@ def coastal_transects( # Reverse transects so all point away from land transect_gdf["geometry"] = transect_gdf.apply( - lambda i: LineString([i.geometry.coords[1], i.geometry.coords[0]]) - if i.p1 < i.p2 - else i.geometry, + lambda i: ( + LineString([i.geometry.coords[1], i.geometry.coords[0]]) + if i.p1 < i.p2 + else i.geometry + ), axis=1, ) @@ -2663,15 +2665,15 @@ def validation_cli( recent_diff.loc["corr"] = -recent_diff.loc[ "corr" ] # Invert as higher corrs are good - recent_diff.loc[ - recent_diff["diff"] < 0, "prefix" - ] = ":heavy_check_mark: improved by " - recent_diff.loc[ - recent_diff["diff"] == 0, "prefix" - ] = ":heavy_minus_sign: no change" - recent_diff.loc[ - recent_diff["diff"] > 0, "prefix" - ] = ":heavy_exclamation_mark: worsened by " + recent_diff.loc[recent_diff["diff"] < 0, "prefix"] = ( + ":heavy_check_mark: improved by " + ) + recent_diff.loc[recent_diff["diff"] == 0, "prefix"] = ( + ":heavy_minus_sign: no change" + ) + recent_diff.loc[recent_diff["diff"] > 0, "prefix"] = ( + ":heavy_exclamation_mark: worsened by " + ) recent_diff["suffix"] = recent_diff["diff"].abs().round(3).replace({0: ""}) recent_diff = ( recent_diff.prefix.astype(str) + recent_diff.suffix.astype(str).str[0:5] diff --git a/tests/test_coastline.py b/tests/test_coastline.py index 13ce47b..536a4ab 100644 --- a/tests/test_coastline.py +++ b/tests/test_coastline.py @@ -1,13 +1,11 @@ import pytest +import json from click.testing import CliRunner from coastlines.raster import generate_rasters_cli from coastlines.vector import generate_vectors_cli from coastlines.continental import continental_cli from coastlines.validation import validation_cli -import os -import json -os.environ['CLICK_DEBUG'] = '1' @pytest.mark.dependency() def test_generate_rasters_cli(): @@ -76,6 +74,7 @@ def test_generate_continental_cli(): # assert result.output == '' # for debugging assert result.exit_code == 0 + @pytest.mark.dependency(depends=["test_generate_continental_cli"]) def test_validation_cli(capsys): runner = CliRunner() @@ -101,9 +100,9 @@ def test_validation_cli(capsys): "output": result.output, "exception": str(result.exception) if result.exception else None, } - + # Convert error_info to a formatted string error_details = json.dumps(error_info, indent=2) - + # Use the detailed error information in the assertion message - assert result.exit_code == 0, f"Command failed. Error details:\n{error_details}" + assert result.exit_code == 0, f"Command failed. Error details:\n{error_details}"