Skip to content

Commit

Permalink
Tests layout change (#232)
Browse files Browse the repository at this point in the history
* Changed layout to try to fix #222
  • Loading branch information
smarie authored Nov 9, 2021
1 parent bc9ca05 commit 4976c00
Show file tree
Hide file tree
Showing 182 changed files with 77 additions and 12 deletions.
8 changes: 5 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ def tests(session: PowerSession, coverage, pkg_specs):
# finally run all tests
if not coverage:
# simple: pytest only
session.run2("python -m pytest --cache-clear -v %s/tests/" % pkg_name)
session.run2("python -m pytest --cache-clear -v tests/")
else:
# coverage + junit html reports + badge generation
session.install_reqs(phase="coverage",
phase_reqs=["coverage", "pytest-html", "genbadge[tests,coverage]"],
versions_dct=pkg_specs)

# --coverage + junit html reports
session.run2("coverage run --source {pkg_name} "
"-m pytest --cache-clear --junitxml={test_xml} --html={test_html} -v {pkg_name}/tests/"
session.run2("coverage run --source src/{pkg_name} "
"-m pytest --cache-clear --junitxml={test_xml} --html={test_html} -v tests/"
"".format(pkg_name=pkg_name, test_xml=Folders.test_xml, test_html=Folders.test_html))
session.run2("coverage report")
session.run2("coverage xml -o {covxml}".format(covxml=Folders.coverage_xml))
Expand All @@ -168,6 +168,8 @@ def flake8(session: PowerSession):
Folders.flake8_reports.mkdir(parents=True, exist_ok=True)
rm_file(Folders.flake8_intermediate_file)

session.cd("src")

# Options are set in `setup.cfg` file
session.run("flake8", pkg_name, "--exit-zero", "--format=html", "--htmldir", str(Folders.flake8_reports),
"--statistics", "--tee", "--output-file", str(Folders.flake8_intermediate_file))
Expand Down
13 changes: 7 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ tests_require =
zip_safe = False
# explicitly setting zip_safe=False to avoid downloading `ply` see https://github.com/smarie/python-getversion/pull/5
# and makes mypy happy see https://mypy.readthedocs.io/en/latest/installed_packages.html
package_dir=
=src
packages = find:
# see [options.packages.find] below
# IMPORTANT: DO NOT set the `include_package_data` flag !! It triggers inclusion of all git-versioned files
# see https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286
# include_package_data = True
[options.packages.find]
where=src
exclude =
contrib
docs
Expand Down Expand Up @@ -96,7 +99,7 @@ test = pytest

# pytest default configuration
[tool:pytest]
testpaths = pytest_cases/tests/
testpaths = tests/
addopts =
--verbose
--doctest-modules
Expand All @@ -112,8 +115,8 @@ filterwarnings =
branch = True
omit = *tests*
# this is done in nox.py (github actions)
# source = pytest_cases
# command_line = -m pytest --junitxml="reports/pytest_reports/pytest.xml" --html="reports/pytest_reports/pytest.html" -v pytest_cases/tests/
# source = src/pytest_cases
# command_line = -m pytest --junitxml="reports/pytest_reports/pytest.xml" --html="reports/pytest_reports/pytest.html" -v tests/

[coverage:report]
fail_under = 70
Expand Down Expand Up @@ -145,6 +148,4 @@ exclude =
tests
noxfile.py
setup.py
tests
_version.py
src/_version.py
*/_version.py
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
setup(
download_url=DOWNLOAD_URL,
use_scm_version={
"write_to": "pytest_cases/_version.py"
"write_to": "src/pytest_cases/_version.py"
}, # we can't put `use_scm_version` in setup.cfg yet unfortunately
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions tests/cases/doc/test_indirect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pytest_cases import parametrize, fixture


@fixture
@parametrize(a=[0, 1])
def my_fix(a):
return a * 2


@fixture
@parametrize(b=[0, 10])
def my_fix2(b, my_fix):
return b + my_fix


def test_foo(my_fix2):
assert my_fix2 in (0, 2, 10, 12)


@parametrize(my_fix=[2], indirect=True)
def test_foo_indirect(my_fix2):
assert my_fix2 in (4, 14)


def test_synthesis(module_results_dct):
assert list(module_results_dct) == [
'test_foo[b=0-a=0]',
'test_foo[b=0-a=1]',
'test_foo[b=10-a=0]',
'test_foo[b=10-a=1]',
'test_foo_indirect[b=0-my_fix=2]',
'test_foo_indirect[b=10-my_fix=2]'
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions tests/cases/issues/test_issue_190.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# import functools
#
# from pytest_cases import parametrize_with_cases, case
#
#
# class CasesFeature:
# @case(tags=("basic",))
# def case_basic(self):
# return 0
#
#
# def release_scope(*scopes):
# if len(scopes) == 0:
# scopes = ["function"]
#
# def decorator(f):
# @functools.wraps(f)
# def wrapper(case, *args, **kw):
# f(case, *args, **kw)
#
# return wrapper
#
# return decorator
#
#
# @parametrize_with_cases("case", cases=CasesFeature, has_tag="basic", scope="session")
# @release_scope()
# def test_container(case):
# pass
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import pytest_cases
from pytest_cases.tests.utils import skip as skip_mark
from tests.utils import skip as skip_mark


@pytest.mark.parametrize('v', [0, skip_mark(1)])
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pytest_cases.fixture_core1_unions import InvalidParamsList
from pytest_cases import fixture, fixture_ref, parametrize
from pytest_cases.tests.conftest import global_fixture
from tests.conftest import global_fixture


@pytest.fixture
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 4976c00

Please sign in to comment.