From 09e98fc18fd5591dc65d806286e8da51b7e384b4 Mon Sep 17 00:00:00 2001 From: Tibor Simko Date: Mon, 20 Feb 2017 18:01:32 +0100 Subject: [PATCH] tests: doctext execution simplification * Performs doctest execution within the initial pytest run, simplifying test suite and solving "disappearing development requirements" when trying the requirements-builder's development level. * Amends test suite code to be inside the test application context in order to assist the pytest doctest discovery. Signed-off-by: Tibor Simko --- docs/conf.py | 3 ++- pytest.ini | 5 +++-- run-tests.sh | 5 ++--- tests/test_invenio_marc21.py | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b31248c..e7745af 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -75,7 +75,8 @@ # Get the version string. Cannot be done with import! g = {} -with open(os.path.join('..', 'invenio_marc21', 'version.py'), 'rt') as fp: +with open(os.path.join(os.path.dirname(__file__), '..', 'invenio_marc21', + 'version.py'), 'rt') as fp: exec(fp.read(), g) version = g['__version__'] diff --git a/pytest.ini b/pytest.ini index 46e72b5..d394eef 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016 CERN. +# Copyright (C) 2016, 2017 CERN. # # Invenio is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as @@ -23,4 +23,5 @@ # as an Intergovernmental Organization or submit itself to any jurisdiction. [pytest] -addopts = --pep8 --ignore=docs --cov=invenio_marc21 --cov-report=term-missing +pep8ignore = docs/conf.py ALL +addopts = --pep8 --doctest-glob="*.rst" --doctest-modules --cov=invenio_marc21 --cov-report=term-missing docs tests invenio_marc21 diff --git a/run-tests.sh b/run-tests.sh index fe11f30..08a48ef 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2016 CERN. +# Copyright (C) 2016, 2017 CERN. # # Invenio is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as @@ -27,5 +27,4 @@ pydocstyle invenio_marc21 && \ isort -rc -c -df **/*.py && \ check-manifest --ignore ".travis-*" && \ sphinx-build -qnNW docs docs/_build/html && \ -python setup.py test && \ -sphinx-build -qnNW -b doctest docs docs/_build/doctest +python setup.py test diff --git a/tests/test_invenio_marc21.py b/tests/test_invenio_marc21.py index ca47444..f2d1d67 100644 --- a/tests/test_invenio_marc21.py +++ b/tests/test_invenio_marc21.py @@ -35,7 +35,6 @@ from invenio_db import db from invenio_indexer.api import RecordIndexer from invenio_records import Record -from invenio_search import current_search as search from invenio_marc21 import InvenioMARC21 @@ -84,10 +83,11 @@ def load_records(es_app, filename, schema): for record in records: es_records.append(indexer.index(record)) + from invenio_search import current_search for record in es_records: - search.client.get(index=record['_index'], - doc_type=record['_type'], - id=record['_id']) + current_search.client.get(index=record['_index'], + doc_type=record['_type'], + id=record['_id']) def test_authority_data(es_app, request):