Skip to content

Commit ba41207

Browse files
committed
tests: use pytest <= nose
1 parent bfcca42 commit ba41207

File tree

9 files changed

+57
-44
lines changed

9 files changed

+57
-44
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ __pycache__/
77
/*.egg*/
88
/build/
99
/dist/
10-
/git-fame_*_amd64.snap
10+
/git-fame_*.snap
1111
/.dockerignore
1212

1313
# Unit test / coverage reports
1414
/.tox/
1515
/.coverage*
1616
/coverage.xml
17-
nosetests.xml
17+
/.pytest_cache/

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ repos:
2525
args: [-i]
2626
types: [text]
2727
exclude: ^(.pre-commit-config.yaml|.github/workflows/test.yml)$
28-
- id: nose
28+
- id: pytest
2929
name: Run tests
3030
language: python
31-
entry: nosetests
32-
args: ['-d', tests/]
31+
entry: pytest
32+
args: [-qq, --durations=1]
3333
types: [python]
3434
pass_filenames: false
3535
additional_dependencies:
36-
- nose
36+
- pytest-timeout
3737
- argopt
3838
- tabulate
3939
- tqdm

Makefile

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
all
99
flake8
1010
test
11-
testnose
11+
pytest
1212
testsetup
1313
testcoverage
1414
testtimer
@@ -17,7 +17,7 @@
1717
prebuildclean
1818
clean
1919
toxclean
20-
installdev
20+
install_dev
2121
install
2222
build
2323
buildupload
@@ -41,13 +41,13 @@ all:
4141
@+make build
4242

4343
flake8:
44-
@+flake8 -j 8 --count --statistics --exit-zero .
44+
@+pre-commit run -a flake8
4545

4646
test:
4747
tox --skip-missing-interpreters -p all
4848

49-
testnose:
50-
nosetests gitfame -d -v
49+
pytest:
50+
pytest
5151

5252
testsetup:
5353
@make gitfame/git-fame.1
@@ -56,10 +56,10 @@ testsetup:
5656

5757
testcoverage:
5858
@make coverclean
59-
nosetests gitfame --with-coverage --cover-package=gitfame --cover-erase --cover-min-percentage=80 -d -v
59+
pytest --cov=gitfame --cov-report=xml --cov-report=term --cov-fail-under=80
6060

6161
testtimer:
62-
nosetests gitfame --with-timer -d -v
62+
pytest
6363

6464
gitfame/git-fame.1: .meta/.git-fame.1.md gitfame/_gitfame.py
6565
python -c 'import gitfame; print(gitfame._gitfame.__doc__.rstrip())' |\
@@ -86,8 +86,9 @@ prebuildclean:
8686
@+python -c "import os; os.remove('gitfame/_dist_ver.py') if os.path.exists('gitfame/_dist_ver.py') else None"
8787
coverclean:
8888
@+python -c "import os; os.remove('.coverage') if os.path.exists('.coverage') else None"
89-
@+python -c "import shutil; shutil.rmtree('gitfame/__pycache__', True)"
89+
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('.coverage.*')]"
9090
@+python -c "import shutil; shutil.rmtree('tests/__pycache__', True)"
91+
@+python -c "import shutil; shutil.rmtree('gitfame/__pycache__', True)"
9192
clean:
9293
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
9394
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('gitfame/*.py[co]')]"
@@ -97,13 +98,13 @@ clean:
9798
toxclean:
9899
@+python -c "import shutil; shutil.rmtree('.tox', True)"
99100

100-
101-
installdev:
102-
python setup.py develop --uninstall
103-
python setup.py develop
104-
105101
install:
106102
python setup.py install
103+
install_dev:
104+
python setup.py develop --uninstall
105+
python setup.py develop
106+
install_build:
107+
python -m pip install -r .meta/requirements-build.txt
107108

108109
build:
109110
@make prebuildclean

gitfame/_gitfame.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def stats_append(fname, auth, loc, tstamp):
316316
try:
317317
inss, dels, fname = i.split('\t')
318318
except ValueError:
319-
log.warn(i)
319+
log.warning(i)
320320
else:
321321
fname = RE_RENAME.sub(r'\\2', fname)
322322
loc = (
@@ -366,7 +366,7 @@ def run(args):
366366
log.debug("parsing args")
367367

368368
if args.sort not in "loc commits files hours months".split():
369-
log.warn("--sort argument (%s) unrecognised\n%s" % (
369+
log.warning("--sort argument (%s) unrecognised\n%s" % (
370370
args.sort, __doc__))
371371
raise KeyError(args.sort)
372372

@@ -430,8 +430,8 @@ def run(args):
430430
churn = CHURN_SLOC
431431

432432
if churn & (CHURN_INS | CHURN_DEL) and args.excl:
433-
log.warn("--loc=ins,del includes historical files"
434-
" which may need to be added to --excl")
433+
log.warning("--loc=ins,del includes historical files"
434+
" which may need to be added to --excl")
435435

436436
auth_stats = {}
437437
statter = partial(

setup.cfg

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ classifiers=
7373
Topic :: Utilities
7474
[options]
7575
setup_requires=setuptools>=42; setuptools_scm[toml]>=3.4
76-
install_requires=argopt>=0.3.5; setuptools; tabulate; tqdm>=4.44.0
7776
python_requires=>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
78-
tests_require=nose; flake8; coverage
77+
install_requires=argopt>=0.3.5; setuptools; tabulate; tqdm>=4.44.0
78+
tests_require=tox
7979
include_package_data=True
8080
packages=find:
8181
[options.extras_require]
@@ -112,6 +112,13 @@ line_length=99
112112
multi_line_output=4
113113
known_first_party=gitfame,tests
114114

115+
[tool:pytest]
116+
timeout=30
117+
log_level=INFO
118+
python_files=tests_*.py
119+
testpaths=tests
120+
addopts=-v --tb=short -rxs -W=error --durations=0 --durations-min=0.1
121+
115122
[coverage:run]
116123
branch=True
117124
omit=

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
except ImportError:
2424
pass
2525

26-
setup(use_scm_version=True, test_suite='nose.collector', ext_modules=ext_modules)
26+
setup(use_scm_version=True, ext_modules=ext_modules)

tests/__init__.py

Whitespace-only changes.

tests/tests_gitfame.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
from tempfile import mkdtemp
88
from textwrap import dedent
99

10-
# import re
11-
# from nose import with_setup
12-
from nose.plugins.skip import SkipTest
10+
from pytest import skip
1311

1412
from gitfame import _gitfame, main
15-
# from io import IOBase # to support unicode strings
1613
from gitfame._utils import StringIO
1714

1815
# test data
@@ -110,8 +107,8 @@ def test_tabulate_yaml():
110107
total: {commits: 35, files: 14, loc: 613}""")]
111108
try:
112109
assert (_gitfame.tabulate(auth_stats, stats_tot, backend='yaml') in res)
113-
except ImportError:
114-
raise SkipTest
110+
except ImportError as err:
111+
raise skip(str(err))
115112

116113

117114
def test_tabulate_json():
@@ -144,8 +141,8 @@ def test_tabulate_tabulate():
144141
-------------------- ----- ------ ------ ---------------
145142
Casper da Costa-Luis 538 35 10 87.8/ 100/71.4
146143
Not Committed Yet 75 0 4 12.2/ 0.0/28.6"""))
147-
except ImportError:
148-
raise SkipTest
144+
except ImportError as err:
145+
raise skip(str(err))
149146

150147

151148
def test_tabulate_enum():
@@ -174,9 +171,12 @@ def test_main():
174171
from os.path import dirname as dn
175172

176173
res = subprocess.Popen(
177-
(sys.executable, '-c', 'import gitfame; import sys;\
178-
sys.argv = ["", "--silent-progress", "%s"];\
179-
gitfame.main()' % dn(dn(__file__))),
174+
(sys.executable, '-c', dedent('''\
175+
import gitfame
176+
import sys
177+
sys.argv = ["", "--silent-progress", "''' + dn(dn(__file__)) + '''"]
178+
gitfame.main()
179+
''')),
180180
stdout=subprocess.PIPE,
181181
stderr=subprocess.STDOUT).communicate()[0]
182182

tox.ini

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,28 @@ python=
2323

2424
[core]
2525
deps=
26-
nose
27-
nose-timer
26+
pytest
27+
py3{5,6}: pytest<7
28+
pytest-cov
29+
pytest-timeout
2830
coverage
2931
coveralls
3032
codecov
33+
commands=
34+
- coveralls
35+
codecov -X pycov -e TOXENV
3136

3237
[testenv]
33-
passenv=TOXENV CI GITHUB_* CODECOV_* COVERALLS_*
38+
passenv=TOXENV CI GITHUB_* CODECOV_* COVERALLS_* HOME
3439
deps=
3540
{[core]deps}
3641
tqdm
3742
pyyaml
3843
commands=
39-
nosetests --with-coverage --with-timer --cover-package=gitfame -d -v tests/
40-
coverage xml
41-
- coveralls
42-
codecov -X pycov -e TOXENV
44+
py{27,py2}: pytest --cov=argopt --cov-report=xml --cov-report=term -o addopts= -v --tb=short -rxs -W=error --durations=10
45+
py3{5,6}: pytest --cov=argopt --cov-report=xml --cov-report=term -o addopts= -v --tb=short -rxs -W=error --durations=0 --durations-min=0.1
46+
py3{7,8,9,10,11}: pytest --cov=argopt --cov-report=xml --cov-report=term
47+
{[core]commands}
4348

4449
[testenv:setup.py]
4550
deps=

0 commit comments

Comments
 (0)