mirror of https://github.com/scrapy/scrapy.git
Merge pull request #6013 from Laerte/master
Handle Tuple type on getdictorlist method, bump 3.12 python version
This commit is contained in:
commit
3318971512
|
|
@ -48,13 +48,13 @@ jobs:
|
|||
env:
|
||||
TOXENV: botocore
|
||||
|
||||
- python-version: "3.12.0-beta.4"
|
||||
- python-version: "3.12.0-rc.1"
|
||||
env:
|
||||
TOXENV: py
|
||||
- python-version: "3.12.0-beta.4"
|
||||
- python-version: "3.12.0-rc.1"
|
||||
env:
|
||||
TOXENV: asyncio
|
||||
- python-version: "3.12.0-beta.4"
|
||||
- python-version: "3.12.0-rc.1"
|
||||
env:
|
||||
TOXENV: extra-deps
|
||||
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ class BaseSettings(MutableMapping[_SettingsKeyT, Any]):
|
|||
def getdictorlist(
|
||||
self,
|
||||
name: _SettingsKeyT,
|
||||
default: Union[Dict[Any, Any], List[Any], None] = None,
|
||||
default: Union[Dict[Any, Any], List[Any], Tuple[Any], None] = None,
|
||||
) -> Union[Dict[Any, Any], List[Any]]:
|
||||
"""Get a setting value as either a :class:`dict` or a :class:`list`.
|
||||
|
||||
|
|
@ -271,6 +271,8 @@ class BaseSettings(MutableMapping[_SettingsKeyT, Any]):
|
|||
return value_loaded
|
||||
except ValueError:
|
||||
return value.split(",")
|
||||
if isinstance(value, tuple):
|
||||
return list(value)
|
||||
assert isinstance(value, (dict, list))
|
||||
return copy.deepcopy(value)
|
||||
|
||||
|
|
|
|||
|
|
@ -1321,6 +1321,17 @@ class FeedExportTest(FeedExportTestBase):
|
|||
yield self.assertExportedCsv(items, ["foo", "egg"], rows_csv)
|
||||
yield self.assertExportedJsonLines(items, rows_jl)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_export_tuple(self):
|
||||
items = [
|
||||
{"foo": "bar1", "egg": "spam1"},
|
||||
{"foo": "bar2", "egg": "spam2", "baz": "quux"},
|
||||
]
|
||||
|
||||
settings = {"FEED_EXPORT_FIELDS": ("foo", "baz")}
|
||||
rows = [{"foo": "bar1", "baz": ""}, {"foo": "bar2", "baz": "quux"}]
|
||||
yield self.assertExported(items, ["foo", "baz"], rows, settings=settings)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_export_feed_export_fields(self):
|
||||
# FEED_EXPORT_FIELDS option allows to order export fields
|
||||
|
|
|
|||
Loading…
Reference in New Issue