Skip to content

Commit afa46b1

Browse files
committed
Fixed #149 Csv with None should return an empty list.
1 parent 39d70aa commit afa46b1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

decouple.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def __init__(self, cast=text_type, delimiter=',', strip=string.whitespace, post_
271271

272272
def __call__(self, value):
273273
"""The actual transformation"""
274+
if value is None:
275+
return self.post_process()
276+
274277
transform = lambda s: self.cast(s.strip(self.strip))
275278

276279
splitter = shlex(value, posix=True)

tests/test_helper_csv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ def test_csv_quoted_parse():
2929
assert ['foo', "'bar, baz'", "'qux"] == csv(''' foo ,"'bar, baz'", "'qux"''')
3030

3131
assert ['foo', '"bar, baz"', '"qux'] == csv(""" foo ,'"bar, baz"', '"qux'""")
32+
33+
34+
def test_csv_none():
35+
csv = Csv()
36+
assert [] == csv(None)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy