Files
@ 93889b9694f4
Branch filter:
Location: rattail-project/rattail/tests/test_csvutil.py - annotation
93889b9694f4
1.1 KiB
text/x-python
bump: version 0.18.12 → 0.19.0
9235b60e7010 92c03f5d8db0 21311b17e249 ee7d0f121060 9fcbdb023c5d ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 | # -*- coding: utf-8; -*-
from io import StringIO
from unittest import TestCase
from unittest.mock import patch
from rattail import csvutil
class TestDictWriter(TestCase):
def test_writeheader_26(self):
# Simulate Python 2.6
with patch('csv.writer'):
with patch('rattail.csvutil.csv.DictWriter', spec=['writer']) as DictWriter:
buf = StringIO()
writer = csvutil.DictWriter(buf, ['field1', 'field2'])
writer.writeheader()
buf.close()
writer.writer.writerow.assert_called_once_with(['field1', 'field2'])
def test_writeheader_27(self):
# Simulate Python 2.7+
with patch('csv.writer'):
with patch('rattail.csvutil.csv.DictWriter', spec=['writer', 'writeheader']) as DictWriter:
buf = StringIO()
writer = csvutil.DictWriter(buf, ['field1', 'field2'])
writer.writeheader()
buf.close()
self.assertFalse(writer.writer.writerow.called)
DictWriter.writeheader.assert_called_once_with(writer)
|