Skip to content

Commit

Permalink
Fixed simple field None value, CenterForOpenScience#238
Browse files Browse the repository at this point in the history
  • Loading branch information
botzill committed Apr 22, 2017
1 parent 7a6de35 commit 7b79037
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pydocx/openxml/wordprocessing/simple_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def _parse_instr_arg_string_to_args(self, arg_string):
return re.findall(r'\s*(?:"([^"]+)"|([^\s]+))+', arg_string)

def parse_instr(self):
if self.instr is None:
return
m = self._parse_instr_into_field_type_and_arg_string()
if not m:
return
Expand Down
4 changes: 4 additions & 0 deletions tests/export/html/test_simple_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def parse(self, instr):
field = SimpleField(instr=instr)
return field.parse_instr()

def test_with_None_instr_returns_None(self):
result = self.parse(None)
self.assertEqual(result, None)

def test_with_blank_instr_returns_None(self):
result = self.parse('')
self.assertEqual(result, None)
Expand Down

0 comments on commit 7b79037

Please sign in to comment.