예제 #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
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