6

I am trying to use tox automating testing in my project. But I am not able to figure out where the logs or prints from my test_methods in python file goes while using tox. I also grepped the entire tox directory for logs but couldn't find it.

Questions

1) How to configure log directory in tox ?

2) What is the default configuration for logs ?

Any Pointers to the documentation and examples ?

My tox.ini file

 [tox]
 minversion = 1.6
 skipsdist = True

 [testenv]
 skip_install = True
 setenv =
     VIRTUAL_ENV={envdir}
 deps = -r{toxinidir}/test-requirements.txt

 passenv = LANG

 [testenv:test]
 commands = ./test.sh --slowest --testr-args='{posargs}'
Knight71
  • 2,927
  • 5
  • 37
  • 63
  • I was able to use the virtual env using .tox//bin/activate . And then do python -m testtools.run to see the actual logs and prints. – Knight71 May 27 '15 at 07:06

4 Answers4

3

it's not really an answer, but I ended up using asserts.. so instead of

print(type(x))

I do

assert type(x)==1

which gives me

E       AssertionError: assert <class 'tuple'> == 1

... so it's a tuple.. A bit crap but it works

Michael Dausmann
  • 4,202
  • 3
  • 35
  • 48
0
  1. There's envlogdir exactly for that:

envlogdir=path

defines a directory for logging where tox will put logs of tool invocation. default: {envdir}/log

  1. By default your testrunner's logs are in ./.tox/envname/log/envname-k.log where envname is environment name (e.g. py27) and k is number of the command which actually runs your testrunner (python -m testtools.run). k==0 is envname creation log, k==1 is log for first dependency installation, etc.
saaj
  • 23,253
  • 3
  • 104
  • 105
  • 2
    But this is not working for me . I see the default directory created and there are two files in it. But none of them contains any print from my test code. They contain only the installation logs. – Knight71 Jun 04 '15 at 11:59
  • @Knight71 If Tox has failed to install the virtualenv or the dependencies it might just haven't run up to executing your test runner. Look at logs you have if there's something reports an error. Also you can append your tox config to the question, so it's easier to reason about your problem. – saaj Jun 04 '15 at 14:59
0

You can use --verbose and throw error intentionaly to print out log Example:

print('HERE')
assertTrue(False)
tox -e unit-tests --verbose
-1

If you use Linux, you can simply log the test using:

tox > toxlog.txt  

And the output will be in the toxlog.txt file