Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add to README how to run tests #1234

Closed
yurivict opened this issue Aug 13, 2022 · 3 comments
Closed

Please add to README how to run tests #1234

yurivict opened this issue Aug 13, 2022 · 3 comments

Comments

@yurivict
Copy link

pytest doesn't find any tests.

@arcondello
Copy link
Member

arcondello commented Aug 14, 2022

python -m unittest

will run the tests with unittest.

I have not personally used pytest, but I believe

pytest tests

should also work.

Note, that to you will also need to build the C++/Cython parts of dimod. Usually done with

python setup.py build_ext --inplace

or

pip install .

@yurivict
Copy link
Author

Test fails for some reason:

 /usr/local/bin/python3.9 -m unittest  -v
dimod (unittest.loader._FailedTest) ... ERROR

======================================================================
ERROR: dimod (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: dimod
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/unittest/loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/local/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/disk-samsung/freebsd-ports/science/py-dimod/work-py39/dimod-0.11.4/dimod/__init__.py", line 18, in <module>
    from dimod.constrained import *
  File "/disk-samsung/freebsd-ports/science/py-dimod/work-py39/dimod-0.11.4/dimod/constrained.py", line 38, in <module>
    from dimod.binary.binary_quadratic_model import BinaryQuadraticModel, Binary, Spin, as_bqm
  File "/disk-samsung/freebsd-ports/science/py-dimod/work-py39/dimod-0.11.4/dimod/binary/__init__.py", line 15, in <module>
    from dimod.binary.binary_quadratic_model import *
  File "/disk-samsung/freebsd-ports/science/py-dimod/work-py39/dimod-0.11.4/dimod/binary/binary_quadratic_model.py", line 41, in <module>
    from dimod.binary.cybqm import cyBQM_float32, cyBQM_float64
  File "/disk-samsung/freebsd-ports/science/py-dimod/work-py39/dimod-0.11.4/dimod/binary/cybqm/__init__.py", line 15, in <module>
    from dimod.binary.cybqm.cybqm_float32 import cyBQM_float32
ModuleNotFoundError: No module named 'dimod.binary.cybqm.cybqm_float32'


----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)

It is run from repo root.
When it is run from dimod/ - no tests are found.

@arcondello
Copy link
Member

The tests are located under tests/ which is why running under dimod/ does not find them. When running from repo root, you need to build the package in place. With python setup.py build_ext --inplace. You could also run the tests from within tests/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants