mirror of https://github.com/scrapy/scrapy.git
backport master fixes to json exporter
This commit is contained in:
parent
06149e0543
commit
cfc2d46d99
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in New Issue