Skip to content

Commit

Permalink
More test improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
ionelmc committed Dec 19, 2014
1 parent 176b18c commit 12b511e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ env:
LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
matrix:
- TOXENV=check
- TOXENV=py26
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
- TOXENV=py26-pytest25
- TOXENV=py27-pytest25
- TOXENV=py33-pytest25
- TOXENV=py34-pytest25
- TOXENV=pypy-pytest25
- TOXENV=py26-pytest26
- TOXENV=py27-pytest26
- TOXENV=py33-pytest26
- TOXENV=py34-pytest26
- TOXENV=pypy-pytest26
before_install:
- python --version
- uname -a
Expand Down
4 changes: 2 additions & 2 deletions src/pytest_benchmark/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ def stddev(self):
return math.sqrt(self.variance)

def __str__(self):
return "Stats[%s runs in %.4fsec, min=%.4fsec, max=%.4fsec, avg=%.4fsec, mean=%.4fsec, stddev=%.4fsec]" % (
self.runs, self.total, self.min, self.max, self.avg, self.mean, self.stddev
return "Stats[%s runs in %.4fsec, min=%.4fsec, max=%.4fsec, mean=%.4fsec, stddev=%.4fsec]" % (
self.runs, self.total, self.min, self.max, self.mean, self.stddev
)
6 changes: 3 additions & 3 deletions tests/test_no_run_broken.t
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ Test that we don't benchmark code that raises exceptions:
def result():
raise Exception()
\s* (re)
tests.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests.py:.* (re)
(_ )+ (re)
.*pytest_benchmark/plugin.py:.*: in __call__ (re)
duration, scale = self._calibrate_timer(runner)
.*pytest_benchmark/plugin.py:.*: in _calibrate_timer (re)
duration = runner(loops)
.*pytest_benchmark/plugin.py:.*: in runner (re)
function_to_benchmark()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
(_ )+ (re)
\s* (re)
@benchmark
def result():
Expand Down
7 changes: 2 additions & 5 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ def test_1():
stats = RunningStats()
for i in 4., 36., 45., 50., 75.:
stats.update(i)
print(stats)
fail
assert stats.mean == 42.0

def test_2():
stats = RunningStats()

stats.update(17.0)
stats.update(19.0)
stats.update(24.0)
print(stats)
fail
assert stats.mean == 20.0
9 changes: 6 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
check,
{py26,py27,py33,py34,pypy},
{py26,py27,py33,py34,pypy}-{pytest25,pytest26},
docs

[testenv]
Expand All @@ -17,11 +17,14 @@ setenv =
PYTHONUNBUFFERED=yes
deps =
cram==0.6
pytest==2.6.4
pytest25: pytest==2.5.2
pytest26: pytest==2.6.4
pytest-cov==1.8.1

testspath = {toxinidir}/tests/test_pytest_benchmark.py
commands = {posargs:cram --verbose tests}
commands =
{posargs:py.test tests}
cram --verbose tests
usedevelop = true

[testenv:spell]
Expand Down

0 comments on commit 12b511e

Please sign in to comment.