use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testDictAssign.
public void testDictAssign() {
PyBlockEvaluator eval = doEvaluate("a={}\na['b']='c'");
Map map = (Map) eval.getValue("a");
assertEquals(1, map.size());
assertEquals("c", map.get("b"));
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testImport.
/**
* Ensures module has any vars imported from external modules
*/
public void testImport() {
myFixture.copyDirectoryToProject("blockEvaluator", "");
final PyFile file = PyUtil.as(myFixture.configureByFile("my_module.py"), PyFile.class);
assert file != null : "Failed to read file";
final PyBlockEvaluator sut = new PyBlockEvaluator();
sut.evaluate(file);
Assert.assertEquals("Failed to read var from package module", "foo", sut.getValueAsString("VARIABLE_IN_PACKAGE_MODULE"));
Assert.assertEquals("Failed to read var from package", "foo", sut.getValueAsString("VARIABLE_IN_PACKAGE"));
Assert.assertEquals("Failed to read list from another module", Arrays.asList("a", "b", "c", "d"), sut.getValueAsList("SOME_LIST"));
Assert.assertEquals("Failed to read var from another module", "42", sut.getValueAsString("SOME_VARIABLE"));
Assert.assertEquals("Failed to read var from another module with alias", "foo", sut.getValueAsString("MY_RENAMED_VAR"));
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testDict.
public void testDict() {
PyBlockEvaluator eval = doEvaluate("a={'b': 'c'}");
Map map = (Map) eval.getValue("a");
assertEquals(1, map.size());
assertEquals("c", map.get("b"));
}
Aggregations