Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
tests: doctext execution simplification
Browse files Browse the repository at this point in the history
* 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 <tibor.simko@cern.ch>
  • Loading branch information
tiborsimko committed Feb 21, 2017
1 parent f721f2a commit 09e98fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__']

Expand Down
5 changes: 3 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
5 changes: 2 additions & 3 deletions run-tests.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions tests/test_invenio_marc21.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 09e98fc

Please sign in to comment.