mako icon indicating copy to clipboard operation
mako copied to clipboard

Use built-in mock on python 3.4

Open sqlalchemy-bot opened this issue 10 years ago • 5 comments

Migrated issue, originally created by theblackcat (@theblackcat)

mako uses the mock package. However, mock is not compatible with python 3.4. Python 3.4 has its own build-in mock tool instead. It would be great if mako used the built-in mock tool if it is available.

sqlalchemy-bot avatar Jul 18 '14 13:07 sqlalchemy-bot

Michael Bayer (@zzzeek) wrote:

not understanding, we already do this: https://bitbucket.org/zzzeek/mako/src/285bc818a50ccc0f9549630f7c4f4c250585c3e7/test/init.py?at=master#cl-65:

if py33:
    from unittest import mock
else:
    import mock

tests run fine on 3.4:

#!

$ python3.4 -m pytest test 
======================================================================= test session starts =======================================================================
platform darwin -- Python 3.4.0 -- py-1.4.20 -- pytest-2.5.2 -- /usr/local/bin/python3.4
collected 387 items / 1 skipped 

test/test_ast.py:272: AstParseTest.test_argument_list PASSED
test/test_ast.py:313: AstParseTest.test_expr_generate PASSED
test/test_ast.py:282: AstParseTest.test_function_decl PASSED
test/test_ast.py:292: AstParseTest.test_function_decl_2 PASSED

...
     ### these are the tests that use mock specifically, "from test import mock" ###
test/test_cmd.py:69: CmdTest.test_file_notfound PASSED
test/test_cmd.py:59: CmdTest.test_file_rt_err PASSED
test/test_cmd.py:43: CmdTest.test_file_success PASSED
test/test_cmd.py:50: CmdTest.test_file_syntax_err PASSED
test/test_cmd.py:33: CmdTest.test_stdin_rt_err PASSED

...

test/test_util.py:33: UtilTest.test_read_file PASSED

============================================================= 378 passed, 10 skipped in 2.26 seconds ==============================================================
 

sqlalchemy-bot avatar Jul 18 '14 14:07 sqlalchemy-bot

theblackcat (@theblackcat) wrote:

setup.py still requires the separate mock package:

line 50:

tests_require=['nose >= 0.11', 'mock'],

sqlalchemy-bot avatar Jul 18 '14 15:07 sqlalchemy-bot

Michael Bayer (@zzzeek) wrote:

we can fix that but is this preventing something? "mock" installs on 3.4 on this end. it just doesn't get used.

sqlalchemy-bot avatar Jul 18 '14 15:07 sqlalchemy-bot

theblackcat (@theblackcat) wrote:

mock's unit tests fail for python 3.4. At least some linux distros are carrying patches to make it work, but the idea is that this is a stop-gap measure until upstream projects stop depending on it.

sqlalchemy-bot avatar Jul 21 '14 09:07 sqlalchemy-bot

Michael Bayer (@zzzeek) wrote:

I dont know python's testing procedures enough to know why the tests in site-packages/ ever get actually run, but feel free to send a short PR for this issue and I can merge it, thanks.

sqlalchemy-bot avatar Jul 21 '14 14:07 sqlalchemy-bot