newField checks its input is a str
Indeed, it takes as input a name (str). For some reason in some test it was given a model. This actually led to some strange failed test.
This commit is contained in:
parent
48c1e668d4
commit
556ef5d34b
@ -231,6 +231,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord)
|
||||
##################################################
|
||||
|
||||
def newField(self, name):
|
||||
assert(isinstance(name, str))
|
||||
f = defaultField.copy()
|
||||
f['name'] = name
|
||||
return f
|
||||
|
@ -39,8 +39,7 @@ def test_fields():
|
||||
assert "{{NewFront}}" in m['tmpls'][0]['qfmt']
|
||||
h = d.models.scmhash(m)
|
||||
# add a field
|
||||
f = d.models.newField(m)
|
||||
f['name'] = "foo"
|
||||
f = d.models.newField("foo")
|
||||
d.models.addField(m, f)
|
||||
assert d.getNote(d.models.nids(m)[0]).fields == ["1", "2", ""]
|
||||
assert d.models.scmhash(m) != h
|
||||
@ -57,8 +56,7 @@ def test_fields():
|
||||
d.models.moveField(m, m['flds'][1], 0)
|
||||
assert d.getNote(d.models.nids(m)[0]).fields == ["1", ""]
|
||||
# add another and put in middle
|
||||
f = d.models.newField(m)
|
||||
f['name'] = "baz"
|
||||
f = d.models.newField("baz")
|
||||
d.models.addField(m, f)
|
||||
f = d.getNote(d.models.nids(m)[0])
|
||||
f['baz'] = "2"
|
||||
|
Loading…
Reference in New Issue
Block a user