mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -05:00
isort tests; black/isort should notice changes to tests
This commit is contained in:
parent
5bb8d317ee
commit
3f0b4ff3f6
13 changed files with 43 additions and 32 deletions
12
Makefile
12
Makefile
|
|
@ -8,6 +8,7 @@ RUNARGS :=
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
BLACKARGS := -t py36 anki aqt tests
|
BLACKARGS := -t py36 anki aqt tests
|
||||||
RUSTARGS := --release --strip
|
RUSTARGS := --release --strip
|
||||||
|
ISORTARGS := anki aqt tests
|
||||||
|
|
||||||
$(shell mkdir -p .build)
|
$(shell mkdir -p .build)
|
||||||
|
|
||||||
|
|
@ -162,12 +163,13 @@ fix: fix-py-fmt fix-py-imports fix-rs-fmt fix-ts-fmt
|
||||||
######################
|
######################
|
||||||
|
|
||||||
PYCHECKDEPS := $(BUILDDEPS) .build/py-check-reqs $(shell find anki aqt -name '*.py' | grep -v buildhash.py)
|
PYCHECKDEPS := $(BUILDDEPS) .build/py-check-reqs $(shell find anki aqt -name '*.py' | grep -v buildhash.py)
|
||||||
|
PYTESTDEPS := $(wildcard tests/*.py)
|
||||||
|
|
||||||
.build/py-mypy: $(PYCHECKDEPS)
|
.build/py-mypy: $(PYCHECKDEPS)
|
||||||
mypy anki aqt
|
mypy anki aqt
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/py-test: $(PYCHECKDEPS) $(wildcard tests/*.py)
|
.build/py-test: $(PYCHECKDEPS) $(PYTESTDEPS)
|
||||||
./tools/tests.sh
|
./tools/tests.sh
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
|
|
@ -175,11 +177,11 @@ PYCHECKDEPS := $(BUILDDEPS) .build/py-check-reqs $(shell find anki aqt -name '*.
|
||||||
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5,_ankirs anki aqt
|
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5,_ankirs anki aqt
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/py-imports: $(PYCHECKDEPS)
|
.build/py-imports: $(PYCHECKDEPS) $(PYTESTDEPS)
|
||||||
isort anki aqt --check # if this fails, run 'make fix-py-imports'
|
isort $(ISORTARGS) --check # if this fails, run 'make fix-py-imports'
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/py-fmt: $(PYCHECKDEPS)
|
.build/py-fmt: $(PYCHECKDEPS) $(PYTESTDEPS)
|
||||||
black --check $(BLACKARGS) # if this fails, run 'make fix-py-fmt'
|
black --check $(BLACKARGS) # if this fails, run 'make fix-py-fmt'
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
|
|
@ -193,7 +195,7 @@ py-fmt: .build/py-fmt
|
||||||
.PHONY: fix-py-imports fix-py-fmt
|
.PHONY: fix-py-imports fix-py-fmt
|
||||||
|
|
||||||
fix-py-imports:
|
fix-py-imports:
|
||||||
isort anki aqt
|
isort $(ISORTARGS)
|
||||||
|
|
||||||
fix-py-fmt:
|
fix-py-fmt:
|
||||||
black $(BLACKARGS) anki aqt
|
black $(BLACKARGS) anki aqt
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
import tempfile, os, shutil
|
import os
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from anki import Collection as aopen
|
from anki import Collection as aopen
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import os.path
|
import os.path
|
||||||
from mock import MagicMock
|
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
|
from mock import MagicMock
|
||||||
from nose2.tools.such import helper
|
from nose2.tools.such import helper
|
||||||
|
|
||||||
from aqt.addons import AddonManager
|
from aqt.addons import AddonManager
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import os, tempfile
|
import os
|
||||||
|
import tempfile
|
||||||
from anki.utils import isWin
|
|
||||||
from tests.shared import assertException, getEmptyCol
|
|
||||||
from anki.stdmodels import addBasicModel, models
|
|
||||||
|
|
||||||
from anki import Collection as aopen
|
from anki import Collection as aopen
|
||||||
|
from anki.stdmodels import addBasicModel, models
|
||||||
|
from anki.utils import isWin
|
||||||
|
from tests.shared import assertException, getEmptyCol
|
||||||
|
|
||||||
|
|
||||||
def test_create_open():
|
def test_create_open():
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import os, tempfile
|
import os
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from nose2.tools.decorators import with_setup
|
from nose2.tools.decorators import with_setup
|
||||||
|
|
||||||
from anki import Collection as aopen
|
from anki import Collection as aopen
|
||||||
from anki.exporting import *
|
from anki.exporting import *
|
||||||
from anki.importing import Anki2Importer
|
from anki.importing import Anki2Importer
|
||||||
|
|
||||||
from .shared import getEmptyCol
|
from .shared import getEmptyCol
|
||||||
|
|
||||||
deck = None
|
deck = None
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from tests.shared import getUpgradeDeckPath, getEmptyCol
|
|
||||||
from anki.utils import ids2str
|
|
||||||
from anki.importing import (
|
from anki.importing import (
|
||||||
Anki2Importer,
|
Anki2Importer,
|
||||||
TextImporter,
|
|
||||||
SupermemoXmlImporter,
|
|
||||||
MnemosyneImporter,
|
|
||||||
AnkiPackageImporter,
|
AnkiPackageImporter,
|
||||||
|
MnemosyneImporter,
|
||||||
|
SupermemoXmlImporter,
|
||||||
|
TextImporter,
|
||||||
)
|
)
|
||||||
|
from anki.utils import ids2str
|
||||||
|
from tests.shared import getEmptyCol, getUpgradeDeckPath
|
||||||
|
|
||||||
testDir = os.path.dirname(__file__)
|
testDir = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from tests.shared import getEmptyCol
|
|
||||||
from anki.utils import stripHTML
|
from anki.utils import stripHTML
|
||||||
|
from tests.shared import getEmptyCol
|
||||||
|
|
||||||
|
|
||||||
def test_latex():
|
def test_latex():
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import tempfile
|
|
||||||
import os
|
import os
|
||||||
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from .shared import getEmptyCol, testDir
|
from .shared import getEmptyCol, testDir
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from tests.shared import getEmptyCol
|
|
||||||
from anki.consts import MODEL_CLOZE
|
|
||||||
from anki.utils import stripHTML, joinFields, isWin
|
|
||||||
import anki.template
|
import anki.template
|
||||||
|
from anki.consts import MODEL_CLOZE
|
||||||
|
from anki.utils import isWin, joinFields, stripHTML
|
||||||
|
from tests.shared import getEmptyCol
|
||||||
|
|
||||||
|
|
||||||
def test_modelDelete():
|
def test_modelDelete():
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import time
|
|
||||||
import copy
|
import copy
|
||||||
|
import time
|
||||||
|
|
||||||
from anki.consts import STARTING_FACTOR
|
from anki.consts import STARTING_FACTOR
|
||||||
from tests.shared import getEmptyCol as getEmptyColOrig
|
|
||||||
from anki.utils import intTime
|
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
|
from anki.utils import intTime
|
||||||
|
from tests.shared import getEmptyCol as getEmptyColOrig
|
||||||
|
|
||||||
|
|
||||||
def getEmptyCol():
|
def getEmptyCol():
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import time
|
|
||||||
import copy
|
import copy
|
||||||
|
import time
|
||||||
|
|
||||||
from anki.consts import STARTING_FACTOR
|
from anki.consts import STARTING_FACTOR
|
||||||
from tests.shared import getEmptyCol
|
|
||||||
from anki.utils import intTime
|
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
|
from anki.utils import intTime
|
||||||
|
from tests.shared import getEmptyCol
|
||||||
|
|
||||||
# Between 2-4AM, shift the time back so test assumptions hold.
|
# Between 2-4AM, shift the time back so test assumptions hold.
|
||||||
lt = time.localtime()
|
lt = time.localtime()
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from tests.shared import getEmptyCol
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from tests.shared import getEmptyCol
|
||||||
|
|
||||||
|
|
||||||
def test_stats():
|
def test_stats():
|
||||||
d = getEmptyCol()
|
d = getEmptyCol()
|
||||||
|
|
@ -27,6 +28,7 @@ def test_graphs_empty():
|
||||||
|
|
||||||
def test_graphs():
|
def test_graphs():
|
||||||
from anki import Collection as aopen
|
from anki import Collection as aopen
|
||||||
|
|
||||||
dir = tempfile.gettempdir()
|
dir = tempfile.gettempdir()
|
||||||
|
|
||||||
d = aopen(os.path.join(dir, "test.anki2"))
|
d = aopen(os.path.join(dir, "test.anki2"))
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from tests.shared import getEmptyCol
|
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
|
from tests.shared import getEmptyCol
|
||||||
|
|
||||||
|
|
||||||
def test_op():
|
def test_op():
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue