Esempio n. 1
0
 public void testPyImportHandling() throws Exception {
   Document doc = new Document("from xxx import yyy");
   PyImportsHandling importsHandling = new PyImportsHandling(doc);
   Iterator<ImportHandle> it = importsHandling.iterator();
   assertTrue(it.hasNext());
   ImportHandle next = it.next();
   assertEquals("from xxx import yyy", next.importFound);
   assertEquals(0, next.startFoundLine);
   assertEquals(0, next.endFoundLine);
   assertFalse(it.hasNext());
 }
Esempio n. 2
0
  public void testPyImportHandling5() throws Exception {

    Document doc = new Document("import threading;\n");
    PyImportsHandling importsHandling = new PyImportsHandling(doc, false);
    Iterator<ImportHandle> it = importsHandling.iterator();
    assertTrue(it.hasNext());
    ImportHandle next = it.next();

    assertEquals("import threading;", next.importFound);
    assertEquals(0, next.startFoundLine);
    assertEquals(0, next.endFoundLine);

    assertTrue(!it.hasNext());
  }
Esempio n. 3
0
  public void testPyImportHandling3() throws Exception {

    Document doc = new Document("from ...a.b import b\nfrom xxx.bbb \\\n    import yyy\n");
    PyImportsHandling importsHandling = new PyImportsHandling(doc);
    Iterator<ImportHandle> it = importsHandling.iterator();
    assertTrue(it.hasNext());
    ImportHandle next = it.next();

    assertEquals("from ...a.b import b", next.importFound);
    assertEquals(0, next.startFoundLine);
    assertEquals(0, next.endFoundLine);

    next = it.next();
    assertEquals("from xxx.bbb \\\n    import yyy", next.importFound);
    assertEquals(1, next.startFoundLine);
    assertEquals(2, next.endFoundLine);

    assertTrue(!it.hasNext());
  }