Commit 8b32fd7a authored by Kirill Smelkov's avatar Kirill Smelkov

Modularize + Start of tests

/cc @jerome
/reviewed-on !1
parents 2c29b2c9 f91a050d
......@@ -248,7 +248,7 @@ def main():
}
tres.update(status)
print(test_result_summary(t.name, tres))
print(_test_result_summary(t.name, tres))
test_result_line.stop(**tres)
# tee, similar to tee(1) utility, copies data from fin to fout appending them to buf.
......@@ -270,10 +270,10 @@ def tee(fin, fout, buf):
buf.append(data)
# test_result_summary returns one-line summary for test result.
# _test_result_summary returns one-line summary for test result.
# it returns something like 'ok # 100t 3f'
# **kw is what is passed to test_result_line.stop().
def test_result_summary(name, kw):
def _test_result_summary(name, kw):
def v(name):
return kw.get(name, '?')
......
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Nexedi SA and Contributors.
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
# verify pytest-related functionality
from nxdtest import _test_result_summary, PyTest
import pytest
# [] of (name, textout, summaryok)
testv = []
def case1(name, textout, summaryok): testv.append((name, textout, summaryok))
case1('ok+xfail', """\
============================= test session starts ==============================
platform linux2 -- Python 2.7.18, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
rootdir: /srv/slapgrid/slappart9/srv/testnode/dfq/soft/46d349541123ed5fc6ceea58fd013a51/parts/zodbtools-dev
collected 43 items
zodbtools/test/test_analyze.py . [ 2%]
zodbtools/test/test_commit.py .x [ 6%]
zodbtools/test/test_dump.py .x. [ 13%]
zodbtools/test/test_tidrange.py ............................. [ 81%]
zodbtools/test/test_zodb.py ........ [100%]
=============== 41 passed, 2 xfailed, 1 warnings in 4.62 seconds ===============
""",
'?\ttestname\t1.000s\t# 43t ?e ?f ?s')
case1('ok+fail', """\
============================= test session starts ==============================
platform linux2 -- Python 2.7.18, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
rootdir: /srv/slapgrid/slappart16/srv/testnode/dfj/soft/8b9988ce0aa31334c6bd56b40e4bba65/parts/pygolang-dev
collected 112 items
golang/_gopath_test.py .. [ 1%]
golang/context_test.py .. [ 3%]
golang/cxx_test.py .. [ 5%]
golang/errors_test.py ........ [ 12%]
golang/fmt_test.py ... [ 15%]
golang/golang_test.py ................................................ [ 58%]
golang/io_test.py . [ 58%]
golang/strconv_test.py .. [ 60%]
golang/strings_test.py ..... [ 65%]
golang/sync_test.py ............. [ 76%]
golang/time_test.py ...F.... [ 83%]
golang/pyx/build_test.py ... [ 86%]
golang/pyx/runtime_test.py . [ 87%]
gpython/gpython_test.py ssssss.sssssss [100%]
=================================== FAILURES ===================================
__________________________________ test_timer __________________________________
def test_timer():
# start timers at x5, x7 and x11 intervals an verify that the timers fire
# in expected sequence. The times when the timers fire do not overlap in
# checked range because intervals are prime and chosen so that they start
# overlapping only after 35 (=5·7).
tv = [] # timer events
Tstart = time.now()
t23 = time.Timer(23*dt)
t5 = time.Timer( 5*dt)
def _():
tv.append(7)
t7f.reset(7*dt)
t7f = time.Timer( 7*dt, f=_)
tx11 = time.Ticker(11*dt)
while 1:
_, _rx = select(
t23.c.recv, # 0
t5 .c.recv, # 1
t7f.c.recv, # 2
tx11.c.recv, # 3
)
if _ == 0:
tv.append(23)
break
if _ == 1:
tv.append(5)
t5.reset(5*dt)
if _ == 2:
assert False, "t7f sent to channel; must only call func"
if _ == 3:
tv.append(11)
Tend = time.now()
assert (Tend - Tstart) >= 23*dt
> assert tv == [ 5, 7, 5, 11, 7, 5, 5, 7,11,23]
E assert [5, 7, 5, 11, 5, 7, ...] == [5, 7, 5, 11, 7, 5, ...]
E At index 4 diff: 5 != 7
E Use -v to get the full diff
golang/time_test.py:106: AssertionError
=============== 1 failed, 98 passed, 13 skipped in 26.85 seconds ===============
""",
'?\ttestname\t1.000s\t# 112t ?e 1f 13s')
@pytest.mark.parametrize("name,textout,summaryok", testv)
def test_pytest_summary(name,textout, summaryok):
kw = {'duration': 1.0}
kw.update(PyTest.summary(textout))
summary = _test_result_summary('testname', kw)
assert summary == summaryok
# nxdtest | pythonic package setup
from setuptools import setup
from setuptools import setup, find_packages
setup(
name = 'nxdtest',
......@@ -12,10 +12,13 @@ setup(
keywords = 'Nexedi testing infrastructure tool tox',
packages = [],
packages = find_packages(),
install_requires = ['erp5.util', 'six'],
extras_require = {
'test': ['pytest'],
},
scripts = ['nxdtest'],
entry_points= {'console_scripts': ['nxdtest = nxdtest:main']},
classifiers = [_.strip() for _ in """\
Development Status :: 3 - Alpha
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment