Skip to content

Commit

Permalink
Merge pull request #13 from ConorMacBride/move-tests
Browse files Browse the repository at this point in the history
Move tests from /tests to /src/mcalf/tests
  • Loading branch information
ConorMacBride committed Jan 18, 2021
2 parents 299e25c + e11e890 commit 7c830d2
Show file tree
Hide file tree
Showing 44 changed files with 81 additions and 19 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ jobs:
install:
- pip3 install --upgrade pip
- pip3 install -e .[tests]
script: python3 -m pytest --cov=mcalf || python -m pytest --cov=mcalf
script:
- >
python3 -m pytest \
-vvv -s -ra \
--pyargs mcalf \
--cov-report=xml --cov=mcalf --cov-config=setup.cfg || \
python -m pytest \
-vvv -s -ra \
--pyargs mcalf \
--cov-report=xml --cov=mcalf --cov-config=setup.cfg
after_script: cd ~
after_success:
- bash <(curl -s https://codecov.io/bash)
16 changes: 5 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,10 @@ Alternatively, you can install MCALF using ``pip``:
Testing
-------

First, install the package as usual, and then download the code
associated with your installed MCALF version.
Unzip the file and navigate to it in the terminal.
Run the following command (in the same directory as ``setup.py``) to test
your installation,

.. code:: bash
$ python -m pytest --cov=mcalf
Make sure you are inside the virtual environment where it was installed.
A test suite is included with the package. The package is tested on
multiple platforms, however you may wish to run the tests on your
system also. More details on running our tox/pytest test suite are
available in our `documentation`_.

Getting Started
---------------
Expand Down Expand Up @@ -166,6 +159,7 @@ MCALF is licensed under the terms of the BSD 2-Clause license.
.. _Anaconda: https://www.anaconda.com/products/individual#Downloads
.. _Miniconda: https://docs.conda.io/en/latest/miniconda.html
.. _new conda environment: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
.. _documentation: https://mcalf.macbride.me/en/latest/guide/index.html#testing

.. _Conor MacBride: https://macbride.me/

Expand Down
66 changes: 60 additions & 6 deletions docs/guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,69 @@ Alternatively, you can install MCALF using ``pip``:
Testing
-------

First, install the package as usual, and then download the code
associated with your installed MCALF version.
Unzip the file and navigate to it in the terminal.
Run the following command (in the same directory as ``setup.py``) to test
A test suite is included with the package. The package is tested on
multiple platforms, however you may wish to run the tests on your
system also.

Installing Dependencies
~~~~~~~~~~~~~~~~~~~~~~~

Using MCALF with pip
====================

To run the tests you need a number of extra packages installed. If you
installed MCALF using pip, you can run ``pip install mcalf[tests]`` to
install the additional testing dependencies (and MCALF if it's not
already installed).

Using MCALF with conda
======================

If you want to use MCALF inside a conda environment you should first
follow the conda installation instructions above. Once MCALF is
installed in a conda environment, ask conda to install each of MCALF's
testing dependencies using the following command.
(See `setup.cfg`_ for an up-to-date list of dependencies.)

.. code:: bash
$ conda install pytest pytest-cov tox
Running Tests
~~~~~~~~~~~~~

Tests should be run within the virtual environment where MCALF and its
testing dependencies were installed. Run the following command to test
your installation,

.. code:: bash
$ python -m pytest --cov=mcalf
$ pytest --pyargs mcalf
Editing the Code
~~~~~~~~~~~~~~~~

If you are planning on making changes to your local version of the code,
it is recommended to run the test suite to help ensure that the changes
do not introduce problems elsewhere.

Before making changes, you'll need to set up a development environment.
The SunPy Community have compiled an excellent set of instructions and
is available in their `documentation`_. You can mostly replace
``sunpy`` with ``mcalf``, and install with

.. code:: bash
$ pip install -e .[tests,docs]
After making changes to the MCALF source, run the MCALF test suite with
the following command (while in the same directory as ``setup.py``),

.. code:: bash
$ pytest --pyargs mcalf --cov
Make sure you are inside the virtual environment where it was installed.
The tox package has also been configured to run the MCALF test suite.

Getting Started
---------------
Expand Down Expand Up @@ -175,6 +227,8 @@ MCALF is licensed under the terms of the BSD 2-Clause license.
.. _Anaconda: https://www.anaconda.com/products/individual#Downloads
.. _Miniconda: https://docs.conda.io/en/latest/miniconda.html
.. _new conda environment: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
.. _setup.cfg: https://github.com/ConorMacBride/mcalf/blob/master/setup.cfg
.. _documentation: https://docs.sunpy.org/en/latest/dev_guide/contents/newcomers.html#setting-up-a-development-environment

.. _Conor MacBride: https://macbride.me/

Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ docs =

[options.packages.find]
where = src

[coverage:run]
omit =
*/mcalf/tests/*
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.
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ envlist =
build_docs

[testenv]
changedir = .tmp/{envname}
setenv =
PYTEST_COMMAND = pytest -vvv -s -ra --cov-report=xml --cov=mcalf
PYTEST_COMMAND = pytest -vvv -s -ra --pyargs mcalf --cov-report=xml --cov=mcalf --cov-config={toxinidir}/setup.cfg
deps =
# Run tests in parallel
pytest-xdist
Expand Down

0 comments on commit 7c830d2

Please sign in to comment.