add tests and setup.py to checks; fix warnings

This commit is contained in:
Damien Elmes 2020-01-06 15:27:59 +10:00
parent 82f0db7583
commit 947d35dfca
10 changed files with 41 additions and 39 deletions

View file

@ -5,8 +5,8 @@ MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules MAKEFLAGS += --no-builtin-rules
RUNARGS := RUNARGS :=
.SUFFIXES: .SUFFIXES:
BLACKARGS := -t py36 anki tests --exclude='backend_pb2|buildinfo' BLACKARGS := -t py36 anki tests setup.py --exclude='backend_pb2|buildinfo'
ISORTARGS := anki tests ISORTARGS := anki tests setup.py
$(shell mkdir -p .build ../dist) $(shell mkdir -p .build ../dist)
@ -58,7 +58,7 @@ CHECKDEPS := $(shell find anki tests -name '*.py')
@touch $@ @touch $@
.build/lint: $(CHECKDEPS) .build/lint: $(CHECKDEPS)
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=ankirspy anki pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=ankirspy anki tests setup.py
@touch $@ @touch $@
.build/imports: $(CHECKDEPS) .build/imports: $(CHECKDEPS)

View file

@ -1,4 +1,4 @@
import setuptools, sys import setuptools
with open("../meta/version") as fh: with open("../meta/version") as fh:
version = fh.read().strip() version = fh.read().strip()
@ -12,15 +12,14 @@ setuptools.setup(
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url="https://apps.ankiweb.net", url="https://apps.ankiweb.net",
packages=setuptools.find_packages(".", exclude=["tests"]), packages=setuptools.find_packages(".", exclude=["tests"]),
classifiers=[ classifiers=[],
], python_requires=">=3.6",
python_requires='>=3.6',
install_requires=[ install_requires=[
'beautifulsoup4', "beautifulsoup4",
'requests', "requests",
'decorator', "decorator",
'protobuf', "protobuf",
'psutil; sys_platform == "win32"', 'psutil; sys_platform == "win32"',
'distro; sys_platform != "darwin" and sys_platform != "win32"' 'distro; sys_platform != "darwin" and sys_platform != "win32"',
] ],
) )

View file

@ -1,4 +1,4 @@
from tests.shared import assertException, getEmptyCol from tests.shared import getEmptyCol
def test_flags(): def test_flags():

View file

@ -10,7 +10,6 @@ from anki.importing import (
SupermemoXmlImporter, SupermemoXmlImporter,
TextImporter, TextImporter,
) )
from anki.utils import ids2str
from tests.shared import getEmptyCol, getUpgradeDeckPath from tests.shared import getEmptyCol, getUpgradeDeckPath
testDir = os.path.dirname(__file__) testDir = os.path.dirname(__file__)

View file

@ -2,7 +2,6 @@
import os import os
import tempfile import tempfile
import time
from .shared import getEmptyCol, testDir from .shared import getEmptyCol, testDir

View file

@ -338,7 +338,7 @@ def test_modelChange():
assert deck.db.scalar("select count() from cards where nid = ?", f.id) == 1 assert deck.db.scalar("select count() from cards where nid = ?", f.id) == 1
def test_templates(): def test_templates2():
d = dict(Foo="x", Bar="y") d = dict(Foo="x", Bar="y")
assert anki.template.render("{{Foo}}", d) == "x" assert anki.template.render("{{Foo}}", d) == "x"
assert anki.template.render("{{#Foo}}{{Foo}}{{/Foo}}", d) == "x" assert anki.template.render("{{#Foo}}{{Foo}}{{/Foo}}", d) == "x"

View file

@ -405,7 +405,7 @@ def test_button_spacing():
def test_overdue_lapse(): def test_overdue_lapse():
# disabled in commit 3069729776990980f34c25be66410e947e9d51a2 # disabled in commit 3069729776990980f34c25be66410e947e9d51a2
return return
d = getEmptyCol() d = getEmptyCol() # pylint: disable=unreachable
# add a note # add a note
f = d.newNote() f = d.newNote()
f["Front"] = "one" f["Front"] = "one"

View file

@ -496,7 +496,7 @@ def test_button_spacing():
def test_overdue_lapse(): def test_overdue_lapse():
# disabled in commit 3069729776990980f34c25be66410e947e9d51a2 # disabled in commit 3069729776990980f34c25be66410e947e9d51a2
return return
d = getEmptyCol() d = getEmptyCol() # pylint: disable=unreachable
# add a note # add a note
f = d.newNote() f = d.newNote()
f["Front"] = "one" f["Front"] = "one"
@ -622,28 +622,30 @@ def test_bury():
d.addNote(f) d.addNote(f)
c2 = f.cards()[0] c2 = f.cards()[0]
# burying # burying
d.sched.buryCards([c.id], manual=True) d.sched.buryCards([c.id], manual=True) # pylint: disable=unexpected-keyword-arg
c.load() c.load()
assert c.queue == -3 assert c.queue == -3
d.sched.buryCards([c2.id], manual=False) d.sched.buryCards([c2.id], manual=False) # pylint: disable=unexpected-keyword-arg
c2.load() c2.load()
assert c2.queue == -2 assert c2.queue == -2
d.reset() d.reset()
assert not d.sched.getCard() assert not d.sched.getCard()
d.sched.unburyCardsForDeck(type="manual") d.sched.unburyCardsForDeck(type="manual") # pylint: disable=unexpected-keyword-arg
c.load() c.load()
assert c.queue == 0 assert c.queue == 0
c2.load() c2.load()
assert c2.queue == -2 assert c2.queue == -2
d.sched.unburyCardsForDeck(type="siblings") d.sched.unburyCardsForDeck( # pylint: disable=unexpected-keyword-arg
type="siblings"
)
c2.load() c2.load()
assert c2.queue == 0 assert c2.queue == 0
d.sched.buryCards([c.id, c2.id]) d.sched.buryCards([c.id, c2.id])
d.sched.unburyCardsForDeck(type="all") d.sched.unburyCardsForDeck(type="all") # pylint: disable=unexpected-keyword-arg
d.reset() d.reset()

View file

@ -5,8 +5,8 @@ MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules MAKEFLAGS += --no-builtin-rules
.SUFFIXES: .SUFFIXES:
BLACKARGS := -t py36 aqt tests --exclude='aqt/forms|buildinfo' BLACKARGS := -t py36 aqt tests setup.py --exclude='aqt/forms|buildinfo'
ISORTARGS := aqt tests ISORTARGS := aqt tests setup.py
$(shell mkdir -p .build ../dist) $(shell mkdir -p .build ../dist)
@ -78,7 +78,7 @@ CHECKDEPS := $(shell find aqt tests -name '*.py')
@touch $@ @touch $@
.build/lint: $(CHECKDEPS) .build/lint: $(CHECKDEPS)
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5,ankirspy aqt pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5,ankirspy aqt tests setup.py
@touch $@ @touch $@
.build/imports: $(CHECKDEPS) .build/imports: $(CHECKDEPS)

View file

@ -1,15 +1,19 @@
import setuptools, sys, os import os
import setuptools
with open("../meta/version") as fh: with open("../meta/version") as fh:
version = fh.read().strip() version = fh.read().strip()
def package_files(directory): def package_files(directory):
entries = [] entries = []
for (path, directories, filenames) in os.walk(directory): for (path, directories, filenames) in os.walk(directory):
entries.append((path, [os.path.join(path, f) for f in filenames])) entries.append((path, [os.path.join(path, f) for f in filenames]))
return entries return entries
extra_files = package_files('aqt_data')
extra_files = package_files("aqt_data")
setuptools.setup( setuptools.setup(
name="aqt", name="aqt",
@ -21,17 +25,16 @@ setuptools.setup(
url="https://apps.ankiweb.net", url="https://apps.ankiweb.net",
packages=setuptools.find_packages(".", exclude=["tests"]), packages=setuptools.find_packages(".", exclude=["tests"]),
data_files=extra_files, data_files=extra_files,
classifiers=[ classifiers=[],
], python_requires=">=3.6",
python_requires='>=3.6',
install_requires=[ install_requires=[
'beautifulsoup4', "beautifulsoup4",
'requests', "requests",
'send2trash', "send2trash",
'pyaudio', "pyaudio",
'markdown', "markdown",
'jsonschema', "jsonschema",
'psutil; sys.platform == "win32"', 'psutil; sys.platform == "win32"',
'pywin32; sys.platform == "win32"', 'pywin32; sys.platform == "win32"',
] ],
) )