瀏覽代碼

fix path in unit tests

nico 8 年之前
父節點
當前提交
7fc60d5231

+ 2 - 1
Tests/test_brain_loader.py

@@ -1,3 +1,4 @@
+import os
 import unittest
 
 from kalliope.core.Models import Singleton
@@ -13,7 +14,7 @@ from kalliope.core.Models.Brain import Brain
 class TestBrainLoader(unittest.TestCase):
 
     def setUp(self):
-        self.brain_to_test = "../Tests/brains/brain_test.yml"
+        self.brain_to_test = os.getcwd() + os.sep + "Tests/brains/brain_test.yml"
         self.expected_result = [
             {'signals': [{'order': 'test_order'}],
              'neurons': [{'say': {'message': ['test message']}}],

+ 2 - 1
Tests/test_settings_loader.py

@@ -1,3 +1,4 @@
+import os
 import platform
 import unittest
 
@@ -14,7 +15,7 @@ class TestSettingLoader(unittest.TestCase):
 
     def setUp(self):
 
-        self.settings_file_to_test = "../Tests/settings/settings_test.yml"
+        self.settings_file_to_test = os.getcwd() + os.sep + "/Tests/settings/settings_test.yml"
 
         self.settings_dict = {
             'rest_api':

+ 2 - 1
Tests/test_yaml_loader.py

@@ -1,3 +1,4 @@
+import os
 import unittest
 
 from kalliope.core.ConfigurationManager.YAMLLoader import YAMLFileNotFound, YAMLLoader
@@ -13,7 +14,7 @@ class TestYAMLLoader(unittest.TestCase):
 
     def test_get_config(self):
 
-        valid_file_path_to_test = "../Tests/brains/brain_test.yml"
+        valid_file_path_to_test = os.getcwd() + os.sep + "Tests/brains/brain_test.yml"
         invalid_file_path = "brains/non_existing_brain.yml"
         expected_result = [
             {'signals': [{'order': 'test_order'}],

+ 4 - 4
kalliope/core/ConfigurationManager/SettingLoader.py

@@ -1,4 +1,3 @@
-import inspect
 import logging
 import os
 
@@ -51,9 +50,10 @@ class SettingLoader(object):
     """
     __metaclass__ = Singleton
 
-    def __init__(self):
-
-        self.file_path = self._get_settings_file_path()
+    def __init__(self, file_path=None):
+        self.file_path = file_path
+        if self.file_path is None:
+            self.file_path = self._get_settings_file_path()
         if self.file_path is None:
             raise SettingNotFound("Settings.yml file not found")
         self.yaml_config = self._get_yaml_config()