Esempio n. 1
0
    def test_if_data_error_is_raised_for_file_with_error(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_with_syntax.py')

        with self.assertRaises(DataError) as cm:
            get_variables(vars_location, [])

        self.assertTrue('SyntaxError: ' in cm.exception.message)
Esempio n. 2
0
    def test_if_data_error_is_raised_for_not_existing_file(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'not_existing.py')

        with self.assertRaises(DataError) as cm:
            get_variables(vars_location, [])

        self.assertTrue(
            'File or directory does not exist' in cm.exception.message)
Esempio n. 3
0
    def test_if_data_error_is_raised_for_file_with_unsupported_extension(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_in_unsupported.robot')

        with self.assertRaises(DataError) as cm:
            get_variables(vars_location, [])

        self.assertTrue(
            'Not a valid file or directory to import' in cm.exception.message)
Esempio n. 4
0
    def test_if_result_is_returned_for_vars_with_argument(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_with_argument.py')

        result = get_variables(vars_location, ['_arg'])

        self.assertEqual(result, {'a': '1_arg', 'b': '2_arg', 'c': '3_arg'})
Esempio n. 5
0
    def test_if_result_is_returned_for_vars_in_class(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_in_class.py')

        result = get_variables(vars_location, [])

        self.assertEqual(result, {'x': '9', 'y': '8', 'z': '7'})
Esempio n. 6
0
    def test_if_result_is_returned_for_vars_in_method(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_in_method.py')

        result = get_variables(vars_location, [])

        self.assertEqual(result, {'a': '1', 'b': '2', 'c': '3'})
Esempio n. 7
0
    def test_if_empty_result_is_returned_for_empty_file(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'empty.py')

        result = get_variables(vars_location, [])

        self.assertEqual(result, {})
Esempio n. 8
0
    def test_if_result_is_returned_with_defined_classes_visible_as_variables(
            self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_class_as_var.py')

        result = get_variables(vars_location, [])

        self.assertSetEqual(set(result.keys()), set(['SomeClass']))
Esempio n. 9
0
def get_variables(path, args, python_paths):
    import os
    cwd = os.getcwd()

    try:
        os.chdir(os.path.dirname(path))
        import red_variables
        __extend_paths(python_paths, [])
        return red_variables.get_variables(path, args)
    finally:
        os.chdir(cwd)
Esempio n. 10
0
    def test_if_result_is_returned_for_vars_in_lines(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_in_lines.py')

        result = get_variables(vars_location, [])

        self.assertEqual(result, {
            'first': '123',
            'second': '234',
            'third': '345'
        })
Esempio n. 11
0
    def test_if_result_is_returned_for_vars_with_proper_casing(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        vars_location = os.path.join(parent_path, 'res_test_red_variables',
                                     'vars_with_case_sensitive_names.py')

        result = get_variables(vars_location, [])

        self.assertEqual(
            result, {
                'first': '123',
                'SECOND': '234',
                'ThIrD': '345',
                'FORTH_with_UnderSCORES': '456'
            })
Esempio n. 12
0
def get_variables(dir, args):
    import red_variables
    return red_variables.get_variables(dir, args)
Esempio n. 13
0
def get_variables(path, args):
    import red_variables
    return red_variables.get_variables(path, args)
Esempio n. 14
0
def get_variables(dir, args):
    import red_variables
    return red_variables.get_variables(dir, args)
Esempio n. 15
0
def get_variables(path, args, python_paths):
    import red_variables
    __extend_paths(python_paths, [])
    return red_variables.get_variables(path, args)