2012-02-06 29 views
11

ile bir sınama sonuçlarını sınar. Aynı anda bunları çalıştırıp sınama işlemlerini bir dosyaya kaydetmeye çalışıyorum. Bunun için çoklu işlem eklentisini ve xunit eklentisini kullanmaya çalışıyorum.Python Burun: Günlüğü, Çoklu İşlem Eklentisi

Birlikte çalışmadıklarının farkındayım, xunit hiçbir şey kaydetmiyor çünkü mutiprocess doğrudan çıktı göndermiyor.

https://github.com/nose-devs/nose/issues/2

Ne Im arayan beni bir dosyaya çıktı yazmak için izin veren herhangi bir alternatiftir. Nedeni, Selenium Testleri'ni çalıştırdığım ve her seferinde bir hata aldığımda, stacktrace o kadar büyük ki, bu kod temel olarak tamamen doldurulur. Hafifleten bir şey de işe yarayabilir, selenyum dökümantasyonu, günlüğe kaydetme çıktısının nasıl yapılandırılacağı konusunda oldukça azdır. Ya

#nosetests > file.txt 

Ama bu doesnt iş:

Ben de stdout oldukça basit bir yeniden yönlendirme çalıştı.

$nosetests --processes 4 --with-xunit --xunit-file=test_output.xml 

Tam örnek:

cevap

14

kabuktan temel yönlendirmeyi kullanmak istiyorsanız sorunuzun dayalı

nosetests &> output.txt 

yapmak Fakat yapabilirsiniz bunu yerine böyle bir şey yapmak istiyorum görünüyor :

$ls 
test_nose.py test_nose.pyc 

$cat test_nose.py 

import sys 
import os 
import time 

def setUp(): 
    pass 

def test_1(): 
    time.sleep(5) 
    with open('test_pid_' + str(os.getpid()), 'w') as f: 
     f.write(str(os.getpid()) + '\n') 

def test_2(): 
    time.sleep(5) 
    with open('test_pid_' + str(os.getpid()), 'w') as f: 
     f.write(str(os.getpid()) + '\n') 

def test_3(): 
    time.sleep(5) 
    with open('test_pid_' + str(os.getpid()), 'w') as f: 
     f.write(str(os.getpid()) + '\n') 

def test_4(): 
    time.sleep(5) 
    with open('test_pid_' + str(os.getpid()), 'w') as f: 
     f.write(str(os.getpid()) + '\n') 

def tearDown(): 
    pass 

$ nosetests --processes 4 --with-xunit --xunit-file=test_output.xml 
.... 
---------------------------------------------------------------------- 
Ran 4 tests in 5.223s 

OK 

$ ls 
test_nose.py test_output.xml test_pid_55247 test_pid_55249 
test_nose.pyc test_pid_55246 test_pid_55248 

$ cat test_pid* 
55246 
55247 
55248 
55249 

$ xmllint -format test_output.xml 
<?xml version="1.0" encoding="UTF-8"?> 
<testsuite name="nosetests" tests="0" errors="0" failures="0" skip="0"/> 

Bu şekilde çalışmıyor gibi görünüyor Eğer :)

Ama

$nosetests --processes 4 &> output.txt 

Ve

$nosetests --with-xunit --xunit-file=test_output.xml 

Do. söyledi

Referanslar:

Redirect stderr and stdout in a Bash script

$man xmllint 

$nosetests -h 
+0

Çok teşekkür ederim, mükemmel çalışıyor! – dgrandes

İlgili konular