Skip to content

Commit

Permalink
Tests: Move ipython magic tests to main unit test suite
Browse files Browse the repository at this point in the history
The `.github/system_tests/test_ipython_magics.py` file provided tests
for the ipython magics, however, these can simply be run in the main
test suite invoked directly through `pytest`.
  • Loading branch information
sphuber committed Nov 16, 2023
1 parent 5b9da7d commit ce9acc3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 deletions.
30 changes: 0 additions & 30 deletions .github/system_tests/test_ipython_magics.py

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ set -ev
# Make sure the folder containing the workchains is in the python path before the daemon is started
SYSTEM_TESTS="${GITHUB_WORKSPACE}/.github/system_tests"

# tests for the testing infrastructure
pytest --cov aiida --verbose --noconftest ${SYSTEM_TESTS}/test_ipython_magics.py

# Until the `${SYSTEM_TESTS}/pytest` tests are moved within `tests` we have to run them separately and pass in the path to the
# `conftest.py` explicitly, because otherwise it won't be able to find the fixtures it provides
AIIDA_TEST_PROFILE=test_aiida pytest --cov aiida --verbose tests/conftest.py ${SYSTEM_TESTS}/pytest
Expand Down
24 changes: 24 additions & 0 deletions tests/tools/ipython/test_ipython_magics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""Tests for :mod:`aiida.tools.ipython.ipython_magics`."""
import textwrap

from IPython.testing.globalipapp import get_ipython

from aiida.tools.ipython.ipython_magics import register_ipython_extension


def test_ipython_magics():
"""Test that the ``%aiida`` magic can be loaded and imports the ``QueryBuilder`` and ``Node`` classes."""
ipy = get_ipython()
register_ipython_extension(ipy)
cell = textwrap.dedent(
"""
%aiida
qb=QueryBuilder()
qb.append(Node)
qb.all()
Dict().store()
"""
)
result = ipy.run_cell(cell)
assert result.success

0 comments on commit ce9acc3

Please sign in to comment.