#!/usr/bin/env python # coding: utf-8 # # Testing # # Before running any tests, you will need to have `pytest` installed. You can install it by running # ``` # python3 -m pip install pytest testpath # ``` # on Linux and MacOS, or # ``` # pip install pytest testpath # ``` # on Windows. # # # ## Recommended full test of installation # # The command # ``` # python3 -c "import oommfc; oommfc.test()" # ``` # will run a test suite to check that OOMMF is installed and accessible, and carry out additional tests of `oommfc`. # # If all tests pass, the last line of the output would read something like: # ``` # ========================= 118 passed in 130.98 seconds ========================= # ``` # If no tests fail: congratulations - you have a working installlation and there is no need to run tests in other sections of this chapter. # # (On Windows machines, please type `python`, instead of `python3`.) # # ## (optional) More detailed installation testing instructions # # 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: # ``` # python3 -m pip install pytest # ``` # or # ``` # pip install pytest # ``` # if you are using Windows machine. # # 1. To test whether oommfc and all its dependencies (except OOMMF) are installed, run: # ``` # python3 -c "import oommfc; oommfc.test_not_oommf()" # ``` # **Note: On Windows machines, please type `python`, instead of `python3`.** # # 2. To check whether `oommfc` can find either OOMMF or Docker on the system, you can run the following commands in your Python kernel: # ``` # import oommfc # oommfc.oommf.status() # ``` # 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: # ``` # oommfc.oommf.status(verbose=True) # ``` # # 3. To get the OOMMF version on your host machine: # ``` # import oommfc # oommfc.oommf.version(where="host") # ``` # or in Docker container # ``` # import oommfc # oommfc.oommf.version(where="docker") # ``` # # 4. To run only `oommfc` tests that require OOMMF, run: # ``` # python3 -c "import oommfc; oommfc.test_oommf()" # ``` # **Note: On Windows machines, please type `python`, instead of `python3`.** # # 5. Complete tests can be executed with: # ``` # python3 -c "import oommfc; oommfc.test()" # ``` # **Note: On Windows machines, please type `python`, instead of `python3`.**