Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

test have to be run from a specific directory #25

Closed
itziakos opened this issue May 21, 2015 · 8 comments
Closed

test have to be run from a specific directory #25

itziakos opened this issue May 21, 2015 · 8 comments
Labels

Comments

@itziakos
Copy link
Member

Running the test suite

python -m unittest discover foam_controlwrapper from any directory except the repo folder fails with the following errors.

======================================================================
ERROR: test_modify_files (foam_controlwrapper.tests.test_foam_files.FoamFilesTestCase)
Test modify_files method
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/enthought/simphony/src/foam-controlwrapper/foam_controlwrapper/tests/test_foam_files.py", line 92, in test_modify_files
    'simplemesh.cuds'))
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/simphony/io/h5_cuds.py", line 57, in open
    handle = tables.open_file(filename, mode, title=title)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/file.py", line 318, in open_file
    return File(filename, mode, title, root_uep, filters, **kwargs)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/file.py", line 784, in __init__
    self._g_new(filename, mode, **params)
  File "tables/hdf5extension.pyx", line 370, in tables.hdf5extension.File._g_new (tables/hdf5extension.c:3987)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/utils.py", line 185, in check_file_access
    check_file_access(filename, 'w')
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/utils.py", line 175, in check_file_access
    raise IOError("``%s`` does not exist" % (parentname,))
IOError: ``foam_controlwrapper/tests`` does not exist

======================================================================
ERROR: test_parallel_run (foam_controlwrapper.tests.test_controlwrapper.FoamControlWrapperTestCase)
Test parallel running of OpenFoam
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/enthought/simphony/src/foam-controlwrapper/foam_controlwrapper/tests/test_controlwrapper.py", line 302, in test_parallel_run
    'simplemesh.cuds'))
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/simphony/io/h5_cuds.py", line 57, in open
    handle = tables.open_file(filename, mode, title=title)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/file.py", line 318, in open_file
    return File(filename, mode, title, root_uep, filters, **kwargs)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/file.py", line 784, in __init__
    self._g_new(filename, mode, **params)
  File "tables/hdf5extension.pyx", line 370, in tables.hdf5extension.File._g_new (tables/hdf5extension.c:3987)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/utils.py", line 185, in check_file_access
    check_file_access(filename, 'w')
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/utils.py", line 175, in check_file_access
    raise IOError("``%s`` does not exist" % (parentname,))
IOError: ``foam_controlwrapper/tests`` does not exist

======================================================================
ERROR: test_run_time (foam_controlwrapper.tests.test_controlwrapper.FoamControlWrapperTestCase)
Test that field variable value is changed after
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/enthought/simphony/src/foam-controlwrapper/foam_controlwrapper/tests/test_controlwrapper.py", line 251, in test_run_time
    'simplemesh.cuds'))
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/simphony/io/h5_cuds.py", line 57, in open
    handle = tables.open_file(filename, mode, title=title)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/file.py", line 318, in open_file
    return File(filename, mode, title, root_uep, filters, **kwargs)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/file.py", line 784, in __init__
    self._g_new(filename, mode, **params)
  File "tables/hdf5extension.pyx", line 370, in tables.hdf5extension.File._g_new (tables/hdf5extension.c:3987)
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/utils.py", line 185, in check_file_access
    check_file_access(filename, 'w')
  File "/home/enthought/simphony/local/lib/python2.7/site-packages/tables/utils.py", line 175, in check_file_access
    raise IOError("``%s`` does not exist" % (parentname,))
IOError: ``foam_controlwrapper/tests`` does not exist

----------------------------------------------------------------------
Ran 40 tests in 3.644s

FAILED (errors=3)

It looks that the test case is a little fagile and expects that the 'simplemesh.cuds' is also installed at a specific directory and that the test runner started from a specific working directory.

One needs to probably adds the 'simplemesh.cuds' to the installation and dynamically discover it during the test run, but this is a temporary solution. It is better not to depend on a file but create the CUDS containers components at runtime. It is also frigile since the cuds hdf5 layout is provisional and so future versions of simphony-common are not expected to be backwards compatible until we stabilise the hdf5 layout and setup a layout versioning.

@itziakos itziakos added the bug label May 21, 2015
@itziakos
Copy link
Member Author

see bugs simphony/simphony-common#148 and simphony/simphony-common#144 for specific bugs regarding the H5Mesh objects that can lead to corrupted data

@itziakos itziakos changed the title Using pyhton setup install breaks the tests test have to be run from a specific directory May 21, 2015
@itziakos
Copy link
Member Author

Corrected description and title, the problems is still there but it is caused not been in the root folder of the repo when running python -m unittest discover foam_controlwrapper. This also means that tests cannnot be run on the installed package if it was installed thought pip

@jmarcelogimenez
Copy link
Contributor

In the current working branch (fix-issues-july2015), we are proposing a dynamic discovery of the mesh file during the test run. It requires adds the 'simplemesh.cuds' to the installation, and look it in the 'site_packages' folder. With this change, the unittest is working from any folder.

As @itziakos said, It is better not to depend on a file but create the CUDS containers components at runtime. But, to do that, we must wait for stabilizing of the hdf5 version.

@itziakos
Copy link
Member Author

As @itziakos said, It is better not to depend on a file but create the CUDS containers components at runtime. But, to do that, we must wait for stabilizing of the hdf5 version.

If the tests create the containers on the fly at runtime there is no need for using the hdf5 backend and thus no reason to wait.

@jmarcelogimenez
Copy link
Contributor

Note: We have returned back with this change. The issue is still open.

@nathanfranklin
Copy link
Member

@khiltunen , i think this can be closed as you fixed it in #53, right?

@khiltunen
Copy link
Contributor

You are right

@nathanfranklin
Copy link
Member

closed by #53

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

No branches or pull requests

4 participants