1. Michael Bayer
  2. mako
  3. Issues

Issues

Issue #230 new

Use built-in mock on python 3.4

theblackcat
created an issue

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.

Comments (5)

  1. Michael Bayer repo owner

    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 ==============================================================
    
  2. theblackcat reporter

    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.

  3. Michael Bayer repo owner

    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.

  4. Log in to comment