Exemple #1
0
    def test_clean_variable_name1(self):
        '''
        It tests the function clean_variable_name when variable names contain ' and spaces.
        '''
        theta_names = [
            "fs.properties.tau['benzene', 'toluene']",
            "fs.properties.tau['toluene', 'benzene' ]"
        ]
        theta_names_new, var_dic, clean = clean_variable_name(theta_names)
        theta_names_expected = [
            "fs.properties.tau[benzene,toluene]",
            "fs.properties.tau[toluene,benzene]"
        ]
        assert len(theta_names_expected) == len(theta_names_new)
        assert all(
            [a == b for a, b in zip(theta_names_expected, theta_names_new)])

        assert len(theta_names_expected) == len(var_dic.keys())
        assert all([
            a == b for a, b in zip(sorted(theta_names_expected),
                                   sorted(var_dic.keys()))
        ])

        assert len(theta_names) == len(var_dic.values())
        assert all([
            a == b
            for a, b in zip(sorted(theta_names), sorted(var_dic.values()))
        ])
        assert clean == True
Exemple #2
0
    def test_clean_variable_name2(self):
        '''
        It tests the function clean_variable_name when variable names do not contain any ' and spaces.
        '''
        theta_names = [
            "fs.properties.tau[benzene,toluene]",
            "fs.properties.tau[toluene,benzene]"
        ]
        theta_names_new, var_dic, clean = clean_variable_name(theta_names)
        assert len(theta_names) == len(theta_names_new)
        assert all([a == b for a, b in zip(theta_names, theta_names_new)])

        assert len(theta_names) == len(var_dic.keys())
        assert all([
            a == b for a, b in zip(sorted(theta_names), sorted(var_dic.keys()))
        ])

        assert len(theta_names) == len(var_dic.values())
        assert all([
            a == b
            for a, b in zip(sorted(theta_names), sorted(var_dic.values()))
        ])
        assert clean == False