diff --git a/tests/test_addons.py b/tests/test_addons.py index f42bc2c5d..954ea8594 100644 --- a/tests/test_addons.py +++ b/tests/test_addons.py @@ -1,8 +1,8 @@ import os.path -from nose.tools import assert_equals from mock import MagicMock from tempfile import TemporaryDirectory from zipfile import ZipFile +from nose2.tools.such import helper from aqt.addons import AddonManager @@ -80,4 +80,4 @@ def assertReadManifest(contents, expectedManifest, nameInZip="manifest.json"): adm = AddonManager(MagicMock()) with ZipFile(zfn, "r") as zfile: - assert_equals(adm.readManifestFile(zfile), expectedManifest) + helper.assertEquals(adm.readManifestFile(zfile), expectedManifest) diff --git a/tests/test_exporting.py b/tests/test_exporting.py index 005bdd011..f1a14d800 100644 --- a/tests/test_exporting.py +++ b/tests/test_exporting.py @@ -1,6 +1,9 @@ # coding: utf-8 -import nose, os, tempfile +import os, tempfile + +from nose2.tools.decorators import with_setup + from anki import Collection as aopen from anki.exporting import * from anki.importing import Anki2Importer @@ -24,7 +27,7 @@ def setup1(): ########################################################################## -@nose.with_setup(setup1) +@with_setup(setup1) def test_export_anki(): # create a new deck with its own conf to test conf copying did = deck.decks.id("test") @@ -65,7 +68,7 @@ def test_export_anki(): d2 = aopen(newname) assert d2.cardCount() == 1 -@nose.with_setup(setup1) +@with_setup(setup1) def test_export_ankipkg(): # add a test file to the media folder with open(os.path.join(deck.media.dir(), "今日.mp3"), "w") as f: @@ -80,7 +83,7 @@ def test_export_ankipkg(): os.unlink(newname) e.exportInto(newname) -@nose.with_setup(setup1) +@with_setup(setup1) def test_export_anki_due(): deck = getEmptyCol() f = deck.newNote() @@ -112,7 +115,7 @@ def test_export_anki_due(): deck2.sched.reset() assert c.due - deck2.sched.today == 1 -# @nose.with_setup(setup1) +# @with_setup(setup1) # def test_export_textcard(): # e = TextCardExporter(deck) # f = unicode(tempfile.mkstemp(prefix="ankitest")[1]) @@ -121,7 +124,7 @@ def test_export_anki_due(): # e.includeTags = True # e.exportInto(f) -@nose.with_setup(setup1) +@with_setup(setup1) def test_export_textnote(): e = TextNoteExporter(deck) fd, f = tempfile.mkstemp(prefix="ankitest") diff --git a/tests/test_find.py b/tests/test_find.py index 9faa1b7bb..cc7e91ede 100644 --- a/tests/test_find.py +++ b/tests/test_find.py @@ -1,5 +1,5 @@ # coding: utf-8 -from nose.tools import assert_raises +from nose2.tools.such import helper from anki.find import Finder from tests.shared import getEmptyCol @@ -100,7 +100,7 @@ def test_findCards(): assert len(deck.findCards("nid:%d"%f.id)) == 2 assert len(deck.findCards("nid:%d,%d" % (f1id, f2id))) == 2 # templates - with assert_raises(Exception): + with helper.assertRaises(Exception): deck.findCards("card:foo") assert len(deck.findCards("'card:card 1'")) == 4 assert len(deck.findCards("card:reverse")) == 1 @@ -136,7 +136,7 @@ def test_findCards(): assert len(deck.findCards("-deck:foo")) == 5 assert len(deck.findCards("deck:def*")) == 5 assert len(deck.findCards("deck:*EFAULT")) == 5 - with assert_raises(Exception): + with helper.assertRaises(Exception): deck.findCards("deck:*cefault") # full search f = deck.newNote() @@ -153,7 +153,7 @@ def test_findCards(): #assert len(deck.findCards("helloworld", full=True)) == 2 #assert len(deck.findCards("back:helloworld", full=True)) == 2 # searching for an invalid special tag should not error - with assert_raises(Exception): + with helper.assertRaises(Exception): len(deck.findCards("is:invalid")) # should be able to limit to parent deck, no children id = deck.db.scalar("select id from cards limit 1") @@ -225,9 +225,9 @@ def test_findCards(): assert len(deck.findCards("added:1")) == deck.cardCount() - 1 assert len(deck.findCards("added:2")) == deck.cardCount() # flag - with assert_raises(Exception): + with helper.assertRaises(Exception): deck.findCards("flag:01") - with assert_raises(Exception): + with helper.assertRaises(Exception): deck.findCards("flag:12") def test_findReplace():