Files
@ 177478f7d054
Branch filter:
Location: rattail-project/rattail/tests/test_csvutil.py - annotation
177478f7d054
1.1 KiB
text/x-python
Database config/init overhaul.
This contains some not-very-atomic changes:
* Get rid of `get_session_class()` function and return to global `Session`
class approach.
* Primary database `Session` is now configured as part of command
initialization, by default.
* Make `config` object available to subcommands, and `Daemon` instances
(the beginning of the end for `edbob.config`!).
* Add `--stdout` and `--stderr` arguments to primary `Command`. These are
in turn made available to subcommands.
* Overhauled some subcommand logic per new patterns.
* Get rid of a few other random references to `edbob`.
* Added and improved several tests.
* Added ability to run tests using arbitrary database engine.
This contains some not-very-atomic changes:
* Get rid of `get_session_class()` function and return to global `Session`
class approach.
* Primary database `Session` is now configured as part of command
initialization, by default.
* Make `config` object available to subcommands, and `Daemon` instances
(the beginning of the end for `edbob.config`!).
* Add `--stdout` and `--stderr` arguments to primary `Command`. These are
in turn made available to subcommands.
* Overhauled some subcommand logic per new patterns.
* Get rid of a few other random references to `edbob`.
* Added and improved several tests.
* Added ability to run tests using arbitrary database engine.
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 ee7d0f121060 ee7d0f121060 ee7d0f121060 ee7d0f121060 |
from unittest import TestCase
from mock import patch
from rattail import csvutil
from cStringIO import StringIO
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)
|