コード例 #1
0
    def _add_import_statement(self, imp_statement, line_col):
        imported_names = get_imported_names(imp_statement)

        if not self._methodBodyChunks or self.setting('useLegacyImportMode'):
            # In the case where we are importing inline in the middle of a
            # source block we don't want to inadvertantly import the module at
            # the top of the file either
            self._importStatements.append(imp_statement)
        self.addImportedVarNames(imported_names, raw_statement=imp_statement)
コード例 #2
0
    def _add_import_statement(self, expr, line_col):
        imp_statement = ''.join(expr)
        imported_names = get_imported_names(imp_statement)

        if not self._methodBodyChunks or self.setting('useLegacyImportMode'):
            # In the case where we are importing inline in the middle of a
            # source block we don't want to inadvertantly import the module at
            # the top of the file either
            self._importStatements.append(imp_statement)
        self.addImportedVarNames(imported_names, raw_statement=imp_statement)
コード例 #3
0
ファイル: ast_utils_test.py プロジェクト: Yelp/yelp_cheetah
def test_get_imported_names(statement, expected):
    assert set(get_imported_names(statement)) == expected
コード例 #4
0
def test_get_imported_names(statement, expected):
    assert set(get_imported_names(statement)) == expected