예제 #1
0
  def test_extract_delete_chunk(self):
    a = ast.parse("""
print a
print b
def foo():
  if c > b :
    print b
    print c
  print d
  print e
  print f
            """)
    b = ast.parse("""
print a
print b
def foo():
  if c > b :
    print c
  print d
  print e
            """)
    diff_tree = diffast.diff(a, b)
    diffast.diff2html(diff_tree)

    contexts = diffast.extract_chunks(diff_tree)
    self.assertEquals(len(contexts), 2)
예제 #2
0
  def test_extract_multiple_delete_chunk(self):
    a = ast.parse("""
print a
print b
if c > b :
  print b
  print c
  print d
  print e
if a > b :
  print a
""")
    b = ast.parse("""
print a
if c > b :
  print b
  print c
if a > b :
  print b
            """)
    diff_tree = diffast.diff(a, b)
    diffast.diff2html(diff_tree)
    contexts = diffast.extract_chunks(diff_tree)

    self.assertEquals(len(contexts), 3)
예제 #3
0
    def _get_chunks(self, a, b):
        a = ast.parse(a)
        b = ast.parse(b)
        diff_tree = diffast.diff(a, b)
        chunks = diffast.extract_chunks(diff_tree)
        for chunk in chunks:
            print '*'
            print chunk
            print '*'

        return chunks, diff_tree.before, diff_tree.after
예제 #4
0
    def test_539508_nova_virt_ironic_driver(self):
        with open(os.path.join("change_539508", "before_driver.py"), "r") as f:
            self.faulty_tree = ast.parse(f.read())
        with open(os.path.join("change_539508", "after_driver.py"), "r") as f:
            self.fixed_tree = ast.parse(f.read())

        diff_tree = diffast.diff(self.faulty_tree, self.fixed_tree)
        diffast.diff2html(diff_tree)
        chunks = diffast.extract_chunks(diff_tree)

        self.assertEquals(len(chunks), 1)
예제 #5
0
    def test_contexts_kolla_client(self):
        with open(os.path.join("change_566719", "before_client.py"), "r") as f:
            self.faulty_tree = ast.parse(f.read())
        with open(os.path.join("change_566719", "after_client.py"), "r") as f:
            self.fixed_tree = ast.parse(f.read())

        diff_tree = diffast.diff(self.faulty_tree, self.fixed_tree)
        diffast.diff2html(diff_tree)
        chunks = diffast.extract_chunks(diff_tree)

        self.assertEquals(len(chunks), 3)
예제 #6
0
    def test_contexts_notifier(self):
        with open(os.path.join("change_569845", "before_notifier.py"), "r") as f:
            self.faulty_tree = ast.parse(f.read())
        with open(os.path.join("change_569845", "after_notifier.py"), "r") as f:
            self.fixed_tree = ast.parse(f.read())

        diff_tree = diffast.diff(self.faulty_tree, self.fixed_tree)
        diffast.diff2html(diff_tree)
        chunks = diffast.extract_chunks(diff_tree)

        self.assertEquals(len(chunks), 4)
예제 #7
0
  def test_extract_modified_chunk(self):
    a = ast.parse("""
print a
    """)
    b = ast.parse("""
print b
    """)
    diff_tree = diffast.diff(a, b)
    diffast.diff2html(diff_tree)
    chunks = diffast.extract_chunks(diff_tree)
    for chunk in chunks:
      print chunk
예제 #8
0
  def test_extract_ctx(self):
    a = ast.parse("""
curr.get()
    """)
    b = ast.parse("""
current.get()
    """)
    diff_tree = diffast.diff(a, b)
    diffast.diff2html(diff_tree)
    chunks = diffast.extract_chunks(diff_tree)
    for chunk in chunks:
      print chunk
예제 #9
0
    def test_567271_nova_compute_resource_tracker(self):
        with open(os.path.join("change_567271", "before_resource_tracker.py"), "r") as f:
            self.faulty_tree = ast.parse(f.read())
        with open(os.path.join("change_567271", "after_resource_tracker.py"), "r") as f:
            self.fixed_tree = ast.parse(f.read())

        diff_tree = diffast.diff(self.faulty_tree, self.fixed_tree)
        diffast.diff2html(diff_tree)
        chunks = diffast.extract_chunks(diff_tree)

        for c in chunks:
            print c
        self.assertEquals(len(chunks), 1)
예제 #10
0
  def test_extract_insert_chunk(self):
    a = ast.parse("""
print a
print b
def foo():
  if c > b :
    print c
  print d
  print e
            """)
    b = ast.parse("""
print a
print b
def foo():
  if c > b :
    print b
    print c
  print d
  print e
  print f
            """)
    diff_tree = diffast.diff(a, b)
    chunks = diffast.extract_chunks(diff_tree)
    self.assertEquals(len(chunks), 2)