Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while printing log capture #631

Open
davisein opened this issue Feb 20, 2013 · 5 comments
Open

Error while printing log capture #631

davisein opened this issue Feb 20, 2013 · 5 comments

Comments

@davisein
Copy link

I am executing nosetests and I get the following error:

Traceback (most recent call last):
  File "/usr/bin/nosetests", line 9, in <module>
    load_entry_point('nose==1.1.2', 'console_scripts', 'nosetests')()
  File "/usr/lib/python2.7/dist-packages/nose/core.py", line 118, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/usr/lib/python2.7/dist-packages/nose/core.py", line 197, in runTests
    result = self.testRunner.run(self.test)
  File "/usr/lib/python2.7/dist-packages/nose/core.py", line 61, in run
    test(result)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 176, in __call__
    return self.run(*arg, **kw)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 223, in run
    test(orig)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 176, in __call__
    return self.run(*arg, **kw)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 223, in run
    test(orig)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 176, in __call__
    return self.run(*arg, **kw)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 223, in run
    test(orig)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 176, in __call__
    return self.run(*arg, **kw)
  File "/usr/lib/python2.7/dist-packages/nose/suite.py", line 223, in run
    test(orig)
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 45, in __call__
    return self.run(*arg, **kwarg)
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 138, in run
    result.addError(self, err)
  File "/usr/lib/python2.7/dist-packages/nose/proxy.py", line 131, in addError
    formatted = plugins.formatError(self.test, err)
  File "/usr/lib/python2.7/dist-packages/nose/plugins/manager.py", line 94, in __call__
    return self.call(*arg, **kw)
  File "/usr/lib/python2.7/dist-packages/nose/plugins/manager.py", line 136, in chain
    result = meth(*arg, **kw)
  File "/usr/lib/python2.7/dist-packages/nose/plugins/logcapture.py", line 223, in formatError
    test.capturedLogging = records = self.formatLogRecords()
  File "/usr/lib/python2.7/dist-packages/nose/plugins/logcapture.py", line 231, in formatLogRecords
    return [safe_str(format(r)) for r in self.handler.buffer]
  File "/usr/lib/python2.7/logging/__init__.py", line 723, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 464, in format
    record.message = record.getMessage()
  File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting

I have tried with the most recent version with pip and I am getting the same error.

Using unittest on that module successfully runs the test (and fails).

The problem probably lies in that the library that I am testing logs quite extensively and some of the logs might be a problem.

Does anybody has an idea of why it is happening?

@jszakmeister
Copy link
Contributor

I suspect this might be fixed on master. Is there any chance you could give it a try, and report whether things work any better? If not, can you post the new traceback? Some things have changed in logcapture.py.

@jsillitoe
Copy link

I just ran into this same issue using version 1.3.1 (and python 3.3).

Traceback (most recent call last):
  File "/home/jrs1/lrssystems/workspace/LRSManager/lrsmanager/tests_unit/test_unit_announce.py", line 50, in test_anouncer_announces_and_logs
announcer.announce('testing')
 File "/home/jrs1/lrssystems/workspace/LRSManager/lrsmanager/announce.py", line 49, in announce
self.logger.log(announcement, context='announce', tag=key)
 File "/home/jrs1/lrssystems/workspace/LRSManager/lrsmanager/logging.py", line 59, in log
pylog.info(message, key)
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 1237, in info
self._log(INFO, msg, args, **kwargs)
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 1372, in _log
self.handle(record)
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 1382, in handle
self.callHandlers(record)
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 1444, in callHandlers
hdlr.handle(record)
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 835, in handle
self.emit(record)
 File "/home/jrs1/lrssystems/workspace/env_lrsmanager_py33/lib/python3.3/site-packages/nose/plugins/logcapture.py", line 82, in emit
self.buffer.append(self.format(record))
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 810, in format
return fmt.format(record)
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 548, in format
record.message = record.getMessage()
 File "/opt/python3.3/lib/python3.3/logging/__init__.py", line 311, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting

@jszakmeister
Copy link
Contributor

Do you have a small test case that can reproduce this issue? It's not clear to me what's happening from the traceback, other than something appears to be mis-configured (more args than format fields).

@jsillitoe
Copy link

When building the simple test case, I realized that my log string was bad. You called it, more args than format fields. Thanks!

@jszakmeister
Copy link
Contributor

@jsillitoe No problem, glad I could help!

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

No branches or pull requests

3 participants