Esempio n. 1
0
 def test_load_working_module(self):
     write_to_file(CONFIG_PATH, 'a = 1')
     module = self.module_loader.load(CONFIG_PATH)
     assert_equal(1, module.a)
Esempio n. 2
0
 def test_load_module_with_type_errors(self):
     write_to_file(CONFIG_PATH, 'a = 1; a()')
     assert_raises(TypeError, self.module_loader.load, CONFIG_PATH)
Esempio n. 3
0
 def test_load_module_with_value_errors(self):
     write_to_file(CONFIG_PATH, 'a,b = [1, 2, 3]')
     assert_raises(ValueError, self.module_loader.load, CONFIG_PATH)
Esempio n. 4
0
 def test_load_module_with_syntax_errors(self):
     write_to_file(CONFIG_PATH, 'a b c')
     assert_raises(SyntaxError, self.module_loader.load, CONFIG_PATH)
Esempio n. 5
0
 def test_load_module_with_name_errors(self):
     write_to_file(CONFIG_PATH, 'a')
     assert_raises(NameError, self.module_loader.load, CONFIG_PATH)
Esempio n. 6
0
 def test_load_working_module(self):
     write_to_file(CONFIG_PATH, 'a = 1')
     module = self.module_loader.load(CONFIG_PATH)
     assert_equal(1, module.a)
Esempio n. 7
0
def ensure_contains_only_formatted_lines(file_path, line_format, n=1):
    ensure_removed(file_path)
    for i in range(n):
        write_to_file(file_path, line_format.format(i))
Esempio n. 8
0
 def test_load_module_with_value_errors(self):
     write_to_file(CONFIG_PATH, 'a,b = [1, 2, 3]')
     assert_raises(ValueError, self.module_loader.load, CONFIG_PATH)
Esempio n. 9
0
 def test_load_module_with_type_errors(self):
     write_to_file(CONFIG_PATH, 'a = 1; a()')
     assert_raises(TypeError, self.module_loader.load, CONFIG_PATH)
Esempio n. 10
0
 def test_load_module_with_name_errors(self):
     write_to_file(CONFIG_PATH, 'a')
     assert_raises(NameError, self.module_loader.load, CONFIG_PATH)
Esempio n. 11
0
 def test_load_module_with_syntax_errors(self):
     write_to_file(CONFIG_PATH, 'a b c')
     assert_raises(SyntaxError, self.module_loader.load, CONFIG_PATH)
Esempio n. 12
0
def ensure_contains_only_formatted_lines(file_path, line_format, n=1):
    ensure_removed(file_path)
    for i in range(n):
        write_to_file(file_path, line_format.format(i))