-1

Guessing this is something to do with STDOUT/STDERR redirection, but the console output is not displayed when running

#!/usr/bin/env python
import subprocess
subprocess.check_output('mocha-phantomjs static/js/tests/headless.html'.split())

The same command in the terminal prints out all the test output

igniteflow
  • 8,404
  • 10
  • 38
  • 46

2 Answers2

1

You should print the output...

#!/usr/bin/env python
import subprocess
print(subprocess.check_output('mocha-phantomjs static/js/tests/headless.html'.split()))
laike9m
  • 18,344
  • 20
  • 107
  • 140
  • Ah, can't believe I missed this! What threw me is the second call I was making to run Python tests with Nose was still outputting to STDOUT without explicitly printing in the Python script. – igniteflow Feb 16 '15 at 10:55
1

check_output() captures subprocess' stdout. Use check_call() to avoid redirecting stdout:

#!/usr/bin/env python
from subprocess import check_call

check_call(['mocha-phantomjs', 'static/js/tests/headless.html'])
jfs
  • 399,953
  • 195
  • 994
  • 1,670