示例#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)