コード例 #1
0
    def test_get_language_from_extension(self, mocked_load_languages):
        """
        Ensure Languages.get_language_from_extension properly gets a language from ext
        """

        def populateDict():
            Languages._languagesDict = {'ext1' : 'lang1', 'ext2' : 'lang2'}
        mocked_load_languages.side_effect = populateDict

        self.assertEqual(Languages.get_language_from_extension('ext1'), 'lang1')
        mocked_load_languages.assert_called_with()

        self.assertEqual(Languages.get_language_from_extension('ext3'), None)
コード例 #2
0
ファイル: solution.py プロジェクト: ucsd-wic-bpc/PyCFramework
    def load_from_path(path):
        """
        Creates a new Solution object from a file at path and returns it
        """
        newSolution = Solution(solutionPath=path)
        filename = fileops.get_basename_less_extension(path)
        filenameMatcher = Definitions.get_value_matcher(Solution.NAMING_DEFINITION_KEY)
        newSolution.problemNumber = filenameMatcher.get_variable_value(
            filename, Variables.get_variable_key_name(Variables.NAME_PROBLEM_NUMBER)
        )
        from util.writer import Writer

        newSolution.solutionWriter = fileops.get_basename(fileops.get_parent_dir(path))
        newSolution.solutionLanguage = Languages.get_language_from_extension(fileops.get_extension(path))

        return newSolution