Closed KKimj closed 3 years ago
https://itkmj.blogspot.com/2019/12/python-pytest-unrecognized-arguments-n.html
$ pip install pytest-xdist
해결 되진 않음.
apt 로 pytest를 설치하면 안된다.
$ sudo apt uninstall python-pytest
# 필요시에
$ sudo apt uninstall python2
$ sudo ln -sf /usr/bin/pip3 /usr/bin/pip
$ pip install pytest
# 아래 결과를 확인한다. (eg., pytest 6.2.2)
$ python -m pytest --version
https://pypi.org/project/pytest-benchmark/
import time
import time
def something(duration=0.000001):
"""
Function that needs some serious benchmarking.
"""
time.sleep(duration)
# You may return anything you want, like the result of a computation
return 123
def test_my_stuff(benchmark):
# benchmark something
result = benchmark(something)
# Extra code, to verify that the run completed correctly.
# Sometimes you may want to check the result, fast functions
# are no good if they return incorrect results :-)
assert result == 123
$ python3 -m pytest test.py
import time
def something(duration=0.000001):
"""
Function that needs some serious benchmarking.
"""
time.sleep(duration)
# You may return anything you want, like the result of a computation
return 123
def test_my_stuff(benchmark):
# benchmark something
result = benchmark(something)
# Extra code, to verify that the run completed correctly.
# Sometimes you may want to check the result, fast functions
# are no good if they return incorrect results :-)
assert result == 123
def test_my_stuff_different_arg(benchmark):
# benchmark something, but add some arguments
result = benchmark(something, 0.001)
assert result == 123
https://github.com/mcchae/pytest-benchmark