diff --git a/plugin/__init__.py b/plugin/__init__.py index fa3cccf..e19f9f2 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -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) diff --git a/tests/test_debug.py b/tests/test_debug.py new file mode 100644 index 0000000..ad1ef02 --- /dev/null +++ b/tests/test_debug.py @@ -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()