mahmoudimus / nose-timer

A timer plugin for nosetests (how much time does every test take?)
MIT License
126 stars 33 forks source link

Fix Windows, python 2.7 support #60

Closed ereOn closed 9 years ago

ereOn commented 9 years ago

On Windows, the current implementation is non-functional with Python 2.7 as the use of the multiprocessing module causes an assertion to fail.

This is all the more a problem because this makes nosetests unusable even when not explicitely specifying the --with-timer option (nosetests basically fails when loading the plugin). Put otherwise, installing nose-timer prevents the use of nosetests altogether in those environments.

This PR is a trivial attempt at fixing this by removing all references to multiprocessing. I'm not too familiar with this module but it seems its only reference was to create a dictionary of some sort.

I replaced it with a regular dict and could ran nose-timer without any problem.

mahmoudimus commented 9 years ago

@ereOn can you first file an issue relating to the bug and exceptions you're seeing?

mahmoudimus commented 9 years ago

@skudriashev I'm still very interested to know what the problem is that @ereOn is trying to solve for.

skudriashev commented 9 years ago

@mahmoudimus Just note that we don't claim we support Windows :)

skudriashev commented 9 years ago

Anyway, I agree - need more details. So, @ereOn, please, post a bug with full description.

ereOn commented 9 years ago

Here is the log with the problem:

(.chromalog2.7) C:\Dev\chromalog>nosetests
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\Lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Python27\Lib\multiprocessing\forking.py", line 488, in prepare
    assert main_name not in sys.modules, main_name
AssertionError: __main__
Traceback (most recent call last):
  File "C:\Python27\Lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Dev\chromalog\.chromalog2.7\Scripts\nosetests.exe\__main__.py", line 9, in <module>
  File "C:\Dev\chromalog\.chromalog2.7\lib\site-packages\nose\core.py", line 121, in __init__
    **extra_args)
  File "C:\Python27\Lib\unittest\main.py", line 94, in __init__
    self.parseArgs(argv)
  File "C:\Dev\chromalog\.chromalog2.7\lib\site-packages\nose\core.py", line 145, in parseArgs
    self.config.configure(argv, doc=self.usage())
  File "C:\Dev\chromalog\.chromalog2.7\lib\site-packages\nose\config.py", line 281, in configure
    options, args = self._parseArgs(argv, cfg_files)
  File "C:\Dev\chromalog\.chromalog2.7\lib\site-packages\nose\config.py", line 268, in _parseArgs
    self.getParser(), self.configSection, file_error=warn_sometimes)
  File "C:\Dev\chromalog\.chromalog2.7\lib\site-packages\nose\config.py", line 590, in getParser
    self.plugins.loadPlugins()
  File "C:\Dev\chromalog\.chromalog2.7\lib\site-packages\nose\plugins\manager.py", line 400, in loadPlugins
    plug = plugcls()
  File "c:\dev\nose-timer\nosetimer\plugin.py", line 24, in __init__
    self._timed_tests = multiprocessing.Manager().dict()
  File "C:\Python27\Lib\multiprocessing\__init__.py", line 99, in Manager
    m.start()
  File "C:\Python27\Lib\multiprocessing\managers.py", line 528, in start
    self._address = reader.recv()
EOFError