{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Testing\n", "\n", "Before running any tests, you will need to have `pytest` installed. You can install it by running\n", "```\n", "python3 -m pip install pytest testpath\n", "```\n", "on Linux and MacOS, or\n", "```\n", "pip install pytest testpath\n", "```\n", "on Windows.\n", "\n", "\n", "## Recommended full test of installation\n", "\n", "The command \n", "```\n", "python3 -c \"import oommfc; oommfc.test()\"\n", "```\n", "will run a test suite to check that OOMMF is installed and accessible, and carry out additional tests of `oommfc`.\n", "\n", "If all tests pass, the last line of the output would read something like:\n", "```\n", "========================= 118 passed in 130.98 seconds =========================\n", "```\n", "If no tests fail: congratulations - you have a working installlation and there is no need to run tests in other sections of this chapter.\n", "\n", "(On Windows machines, please type `python`, instead of `python3`.)\n", "\n", "## (optional) More detailed installation testing instructions\n", "\n", "There are several ways how we can test if our OOMMFC and OOMMF are installed correctly. To run the tests, `pytest` should be installed. To install it, run:\n", "```\n", "python3 -m pip install pytest\n", "```\n", "or\n", "```\n", "pip install pytest\n", "```\n", "if you are using Windows machine.\n", "\n", "1. To test whether oommfc and all its dependencies (except OOMMF) are installed, run:\n", "```\n", "python3 -c \"import oommfc; oommfc.test_not_oommf()\"\n", "```\n", "**Note: On Windows machines, please type `python`, instead of `python3`.**\n", "\n", "2. To check whether `oommfc` can find either OOMMF or Docker on the system, you can run the following commands in your Python kernel:\n", "```\n", "import oommfc\n", "oommfc.oommf.status()\n", "```\n", "The function `status` returns a dictionary showing whether or not OOMMF and docker can be found on the host machine. For example. {\"host\": True, \"docker\": False} means that OOMMF can be found on the host machine, but Docker cannot. If both are `False`, to diagnose the issue run:\n", "```\n", "oommfc.oommf.status(verbose=True)\n", "```\n", "\n", "3. To get the OOMMF version on your host machine:\n", "```\n", "import oommfc\n", "oommfc.oommf.version(where=\"host\")\n", "```\n", "or in Docker container\n", "```\n", "import oommfc\n", "oommfc.oommf.version(where=\"docker\")\n", "```\n", "\n", "4. To run only `oommfc` tests that require OOMMF, run:\n", "```\n", "python3 -c \"import oommfc; oommfc.test_oommf()\"\n", "```\n", "**Note: On Windows machines, please type `python`, instead of `python3`.**\n", "\n", "5. Complete tests can be executed with:\n", "```\n", "python3 -c \"import oommfc; oommfc.test()\"\n", "```\n", "**Note: On Windows machines, please type `python`, instead of `python3`.**" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 1 }