Skip to content

Commit

Permalink
Adjust after merge of iiasa/ixmp#397
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Feb 19, 2021
1 parent b92cb54 commit 7561ce7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions genno/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def handles(section_name: str, iterate: bool = True, discard: bool = True):
Parameters
----------
section_name: str
The name of the configuration section to handle. Using a name already present
in :data:`HANDLERS` overrides that handler.
iterate : bool, optional
If :obj:`True`, the handler is called once for each item (either list item, or
(key, value) tuple) in the section. If :obj:`False`, the entire section
Expand Down
14 changes: 9 additions & 5 deletions genno/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
from genno.config import HANDLERS, handles


# NB ixmp is currently used in the genno test suite: ixmp.testing.run_notebook is
# imported by test_exceptions.py. This in turn cases ixmp to register its own
# handlers: 2 new, and 1 overriding the built-in one for "units:".
THIRD_PARTY_HANDLERS = 2


def test_handlers():
# Expected config handlers are available
# NB "+ 1" is because ixmp.testing is imported by test_exceptions.py, which in turn
# causes ixmp to register its own handler. This should be *commented* when using
# code from https://github.com/iiasa/ixmp/pull/397; or *uncommented* otherwise/
# after that PR is merged
assert len(HANDLERS) == 8 + (1 * HAS_PYAM) # + 1
assert 8 + (1 * HAS_PYAM) + THIRD_PARTY_HANDLERS == len(HANDLERS)

# Handlers are all callable
for key, func in HANDLERS.items():
assert isinstance(key, str) and callable(func)

Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ setup_requires =


[options.extras_require]
# Graphviz, for Computer.describe()
graphviz =
graphviz
docs =
IPython
sphinx_rtd_theme
Expand All @@ -56,6 +59,7 @@ compat =
%(pyam)s
tests =
%(compat)s
%(graphviz)s
ixmp
pytest
pytest-cov
Expand Down

0 comments on commit 7561ce7

Please sign in to comment.