Exemplo n.º 1
0
    t3 = table(data = [
      ( 4, 5, 6 ),
    ])
    t4 = table(data = [])

    t1.remove_row(0)
    self.assertEqual( t1, t2 )

    t1.remove_row(1)
    self.assertEqual( t1, t3 )

    t1.remove_row(0)
    self.assertEqual( t1, t4 )

  def test_remove_row_with_key(self):
    self.maxDiff = None
    t = table(data = [
      ( 'cherry', 'red', 4 ),
      ( 'lemon', 'yellow', 2 ),
      ( 'orange', 'orange', 8 ),
      ( 'mango', 'orange', 10 ),
    ], column_names = ( 'fruit', 'color', 'sweetness' ))
    t.remove_row_with_key(lambda row: row.color == 'orange')
    self.assertEqual( [
      ( 'cherry', 'red', 4 ),
      ( 'lemon', 'yellow', 2 ),
    ], t )
    
if __name__ == '__main__':
  unit_test.main()
Exemplo n.º 2
0
            f(output)
            self.assertTrue(
                'Ref that is both a branch and tag is not supported' in str(
                    ctx.exception))

    def test_parse_show_ref_output_only_heads(self):
        f = git_ref_info.parse_show_ref_output

        output = '''\
deadbeefdeadbeefdeadbeefdeadbeefdeadbeef refs/heads/test1
'''
        self.assertEqual(
            ('test1', 'refs/heads/test1', 'branch',
             'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef', 'deadbee', False),
            f(output))

    def test_parse_show_ref_output_only_remotes(self):
        f = git_ref_info.parse_show_ref_output

        output = '''\
deadbeefdeadbeefdeadbeefdeadbeefdeadbeef refs/remotes/origin/test1
'''
        self.assertEqual(
            ('test1', 'refs/remotes/origin/test1', 'branch',
             'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef', 'deadbee', True),
            f(output))


if __name__ == '__main__':
    unit_test.main()