trend.py and test_trend.py are in the same folder. I have a class Trend with a function find_regres_values that is called from a instance method perform_analysis.
trend.py:
class Trend: def __init__(self, values, trend_type): self.all_values = values def permorn_analysis(self, first, trend_type): #blabla vals_reg = ["a", "b", "c", "d"] find_regres_values(vals_reg, first, trend_type) def find_regres_values(vals_reg, first, trend_type): #do somethin pass in test_trend.py
from trend import find_regres_values class ConsecRegions(unittest.TestCase): def test_find_regres_values_decreas_min_before_max(self): #initialize some values output = find_regres_values(vals_reg, first, trend_type) self.assertEqual(output, result) It shows me an error:
File "test_trend.py", line 2, in <module> from trend import find_regres_values ImportError: cannot import name find_regres_values How do I import one function for testing?
class. You will need to import that class and then (instantiate if need) use the method.