Do not strip() during dupe check (#171)

This commit is contained in:
Scott Noyes 2020-05-08 19:16:05 -05:00 committed by GitHub
parent 2ca35712f3
commit 80d830caed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -236,7 +236,7 @@ class AnkiConnect:
# dupeOrEmpty returns if a note is a global duplicate
# the rest of the function checks to see if the note is a duplicate in the deck
val = note.fields[0].strip()
val = note.fields[0]
did = deck['id']
csum = anki.utils.fieldChecksum(val)

23
tests/test_debug.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
import unittest
import util
class TestNotes(unittest.TestCase):
def setUp(self):
util.invoke('createDeck', deck='test')
def tearDown(self):
util.invoke('deleteDecks', decks=['test'], cardsToo=True)
def test_bug164(self):
note = {'deckName': 'test', 'modelName': 'Basic', 'fields': {'Front': ' Whitespace\n', 'Back': ''}, 'options': { 'allowDuplicate': False, 'duplicateScope': 'deck'}}
util.invoke('addNote', note=note)
self.assertRaises(Exception, lambda: util.invoke('addNote', note=note))
if __name__ == '__main__':
unittest.main()