Anki/tests/shared.py
2011-11-23 17:47:44 +09:00

23 lines
543 B
Python

import tempfile, os, shutil
from anki import open as aopen
def assertException(exception, func):
found = False
try:
func()
except exception:
found = True
assert found
def getEmptyDeck(**kwargs):
(fd, nam) = tempfile.mkstemp(suffix=".anki2")
os.unlink(nam)
return aopen(nam, **kwargs)
def getUpgradeDeckPath():
src = os.path.join(testDir, "support", "anki12.anki")
(fd, dst) = tempfile.mkstemp(suffix=".anki2")
shutil.copy(src, dst)
return dst
testDir = os.path.dirname(__file__)