Tests using python-mock are brittle

Bug #807360 reported by Muharem Hrnjadovic
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenQuake (deprecated)
Fix Released
High
Anton Gritsay

Bug Description

When the signature of a mocked function changes for example the tests will not break. We should revisit all tests and make use of http://www.voidspace.org.uk/python/mock/mocksignature.html

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

$ find tests -name \*.py | xargs grep -i patch
tests/alchemy_db_utils_unittest.py: with mock.patch('sqlalchemy.create_engine') as ce_mock:
tests/alchemy_db_utils_unittest.py: with mock.patch('sqlalchemy.orm.sessionmaker') as sm_mock:
tests/alchemy_db_utils_unittest.py: with mock.patch('sqlalchemy.create_engine') as ce_mock:
tests/alchemy_db_utils_unittest.py: with mock.patch('sqlalchemy.orm.sessionmaker') as sm_mock:
tests/kvs_unittest.py: with mock.patch('redis.client.Redis.delete') as delete_mock:
tests/tools_dbmaint_unittest.py: with mock.patch('tools.dbmaint.psql') as mock_psql:
tests/tools_dbmaint_unittest.py: with mock.patch('tools.dbmaint.psql') as mock_psql:
tests/cache_gc_unittest.py: with mock.patch('openquake.kvs.cache_gc') as gc_mock:

Changed in openquake:
status: New → Confirmed
importance: Undecided → High
tags: added: broken-test sys-quality
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

In openquake-server:

db_tests/mtapi_views_unittest.py: with mock.patch('subprocess.Popen', new=popen_mock):
db_tests/bin_oqrunner_unittest.py: with mock.patch('bin.oqrunner.register_shapefiles_in_location') \
db_tests/bin_oqrunner_unittest.py: with mock.patch('bin.oqrunner.update_layers'):
db_tests/bin_oqrunner_unittest.py: with mock.patch('bin.oqrunner.register_shapefiles_in_location') \
db_tests/bin_oqrunner_unittest.py: with mock.patch('bin.oqrunner.update_layers'):
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
db_tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:
tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.is_process_running') as mock_func:
tests/bin_oqrunner_unittest.py: with mock.patch('subprocess.Popen', new=popen_mock):
tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.is_process_running') as mock_func:
tests/bin_oqrunner_unittest.py: with mock.patch('subprocess.Popen', new=popen_mock):
tests/bin_oqrunner_unittest.py: with mock.patch('geonode.mtapi.view_utils.run_cmd') as mock_func:

John Tarter (toh2)
Changed in openquake:
milestone: none → 0.4.3
John Tarter (toh2)
Changed in openquake:
assignee: nobody → Anton Gritsay (angri)
Anton Gritsay (angri)
Changed in openquake:
status: Confirmed → In Progress
Anton Gritsay (angri)
Changed in openquake:
status: In Progress → Fix Committed
Changed in openquake:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.