backport master fixes to json exporter

This commit is contained in:
Daniel Graña 2013-09-05 16:57:27 -03:00
parent 06149e0543
commit cfc2d46d99
2 changed files with 9 additions and 2 deletions

View File

@ -79,7 +79,7 @@ class BaseItemExporter(object):
class JsonLinesItemExporter(BaseItemExporter):
def __init__(self, file, **kwargs):
self._configure(kwargs)
self._configure(kwargs, dont_fail=True)
self.file = file
self.encoder = ScrapyJSONEncoder(**kwargs)
@ -91,7 +91,7 @@ class JsonLinesItemExporter(BaseItemExporter):
class JsonItemExporter(JsonLinesItemExporter):
def __init__(self, file, **kwargs):
self._configure(kwargs)
self._configure(kwargs, dont_fail=True)
self.file = file
self.encoder = ScrapyJSONEncoder(**kwargs)
self.first_item = True

View File

@ -233,6 +233,13 @@ class JsonLinesItemExporterTest(BaseItemExporterTest):
exported = json.loads(self.output.getvalue())
self.assertEqual(exported, self._expected_nested)
def test_extra_keywords(self):
self.ie = self._get_exporter(sort_keys=True)
self.test_export_item()
self._check_output()
self.assertRaises(TypeError, self._get_exporter, foo_unknown_keyword_bar=True)
class JsonItemExporterTest(JsonLinesItemExporterTest):
_expected_nested = [JsonLinesItemExporterTest._expected_nested]