Skip to content

Commit

Permalink
Refactor for pytest filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
berrli committed Aug 7, 2024
1 parent ee2e77b commit 537ea8b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion environmental_insights/air_pollution_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import matplotlib.patches as mpatches
from matplotlib import colors
import numpy as np
from . import variables
import environmental_insights.variables as variables # Absolute import
from pathlib import Path

pd.options.mode.chained_assignment = None # default='warn'
Expand Down
2 changes: 1 addition & 1 deletion environmental_insights/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pickle
import os
import pandas as pd
from . import variables
import environmental_insights.variables as variables # Absolute import
import numpy as np


Expand Down
5 changes: 4 additions & 1 deletion tests/test_air_pollution_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest
import sys
sys.path.append("../environmental_insights/") # Adds higher directory to python modules path.
import os

# Add the parent directory to the system path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../environmental_insights')))
import air_pollution_functions as ei_air_pollution_functions
import data as ei_data

Expand Down
7 changes: 6 additions & 1 deletion tests/test_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import unittest
import sys

sys.path.append("../environmental_insights/") # Adds higher directory to python modules path.
import sys
import os

# Add the parent directory to the system path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../environmental_insights')))

import air_pollution_functions as ei_air_pollution_functions
import data as ei_data

Expand Down
14 changes: 13 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import unittest
import sys
import os

# Add the parent directory to the system path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../environmental_insights')))

import sys
import os

# Calculate the absolute path to the module's directory
module_path = os.path.abspath(os.path.join('..', 'environmental_insights'))

# Add this directory to the system path
sys.path.insert(0, module_path)

sys.path.append("../environmental_insights/") # Adds higher directory to python modules path.
import air_pollution_functions as ei_air_pollution_functions
import data as ei_data
import models as ei_models
Expand Down

0 comments on commit 537ea8b

Please sign in to comment.