def testUtf8CsvReaderWhenSkipLeadingRows(self):
    skip_leading_rows = 1
    input_path = '/path/to/file'

    self._SetupTestFlags(skip_leading_rows=skip_leading_rows)
    csv_writer = self.mox.CreateMockAnything()
    self.mox.StubOutWithMock(load_lib.csv, 'reader')

    header_row = '#header'

    class TestList(list):
      """Lazy container built on list and fake next() method, for testing."""

      def next(self):  # pylint: disable=invalid-name
        return header_row
    csv_reader = TestList([['line0'], ['line1']])
    self.stubs.Set(csv_reader, 'next', lambda: header_row)

    expect_kwargs = {'dialect': 'excel', 'foo': 'bar'}
    load_lib.csv.reader(input_path, **expect_kwargs).AndReturn(csv_reader)
    csv_writer.writerow(header_row)
    i = 0

    self.mox.ReplayAll()
    reader = load_lib._Utf8CsvReader(
        input_path, foo='bar', skip_rows_writer=csv_writer)
    for row in reader:
      self.assertTrue(i <= len(csv_reader))
      self.assertEqual(row, csv_reader[i])
      i += 1
    self.mox.VerifyAll()
Test _Utf8CsvReader().
dataset/ETHPy150Open google/encrypted-bigquery-client/src/load_lib_test.py/LoadLibraryTest.testUtf8CsvReaderWhenSkipLeadingRows