Diferencia entre revisiones de «Usuario:Lmorillas/intropyaytozgz/nose»

De WikiEducator
Saltar a: navegación, buscar
 
Línea 4: Línea 4:
 
{{Conocimiento previo|
 
{{Conocimiento previo|
 
Tests con python:
 
Tests con python:
 +
* http://en.wikipedia.org/wiki/Portal:Software_Testing
 
* http://docs.python.org/2/library/unittest.html
 
* http://docs.python.org/2/library/unittest.html
 
* https://nose.readthedocs.org/en/latest/index.html
 
* https://nose.readthedocs.org/en/latest/index.html
 +
* http://ivory.idyll.org/articles/nose-intro.html
 
}}
 
}}
  
== Ejemplos ==
 
  
   def test():
+
== Instalar nose ==
      assert False
+
Puedes usar pip o easy_install:
 +
easy_install nose
 +
o
 +
pip install nose
 +
 
 +
O instalar desde el código fuente:
 +
python setup.py install
 +
 
 +
Escribe los tests en el proyecto y:Now you can run tests for your project:
 +
   cd path/del/proyecto
 +
  nosetests
 +
Verás algo así:
 +
  ..................................
 +
  ----------------------------------------------------------------------
 +
  Ran 34 tests in 1.440s
 +
 
 +
  OK
 +
 
 +
==Escribir tests==
 +
Mira estos [http://learnpythonthehardway.org/book/ex47.html ejemplos]
 +
 
 +
<source lang="python">
 +
def test_a():
 +
    assert ...
 +
 
 +
</source>
 +
 
 +
Para comprobar:
 +
 
 +
  $ nosetests
 +
 
 +
== Más Ejemplos ==
  
 
<source lang="python">
 
<source lang="python">

Última revisión de 02:26 11 dic 2012






Instalar nose

Puedes usar pip o easy_install:

easy_install nose

o

pip install nose

O instalar desde el código fuente:

python setup.py install

Escribe los tests en el proyecto y:Now you can run tests for your project:

 cd path/del/proyecto
 nosetests

Verás algo así:

 ..................................
 ----------------------------------------------------------------------
 Ran 34 tests in 1.440s
 
 OK

Escribir tests

Mira estos ejemplos

def test_a():
    assert ...

Para comprobar:

 $ nosetests

Más Ejemplos

#testset.py
from nose.tools import ok_, eq_, nottest
 
def test_sum():
    eq_(2+2,4)
 
@nottest   # este test no empieza por test_
def test_failing_sum():
    ok_(2+2 == 3, "Expected failure")