Upgrade to Pro — share decks privately, control downloads, hide ads and more …

a quick look at webtest & pytest

3718792073b1fd9aef81fc23a35bb825?s=47 Jakub Jarosz
December 10, 2014

a quick look at webtest & pytest

a short overview of webtest and pytest with real world examples of unit, integration and system tests

3718792073b1fd9aef81fc23a35bb825?s=128

Jakub Jarosz

December 10, 2014
Tweet

Transcript

  1. webtest & pytest a quick look at Python Ireland Meetup

    - December 2014 Jakub Jarosz @qba73
  2. webtest • test webapp without HTTP srv • full stack

    functional / integration testing • does not replace unit tests!
  3. webtest - testing wsgi app Our app ready for testing

    (no http srv)
  4. webtest - testing non wsgi app

  5. webtest - testing non wsgi app

  6. pytest - basic

  7. pytest - basic verbose mode (test names)

  8. pytest - fixture decorator

  9. pytest - fixture decorator / caching

  10. pytest - fixture scope • session • package • module

    • class • function Global fixtures Module fixtures
  11. pytest - fixture scope module fixture module fixture

  12. pytest - interdependent fixtures / scope apiapp - global fixture,

    session level module level fixture
  13. pytest - xfail global fixture, session level

  14. pytest - using markers global fixture mark tests that do

    not change user data
  15. pytest - using markers global fixture pytest marker py.test tests/

    -v -m “e2e” py.test tests/ -v -m “not e2e”
  16. pytest - parametrized fixtures the same param! global fixture, session

    scope
  17. pytest - parametrized fixtures • pytest automatically generates tests with

    given parameters. • It is a perfect solution for data driven tests with the same business logic.
  18. pytest - parametrized fixtures

  19. pytest - finalizers aka tearDown()

  20. pytest - hooks project - myapp - tests - conftest.py

    - test_module1.py - test_module2.py • pytest_sessionstart() • pytest_sessionfinish() • pytest_runtestsetup() • pytest_runtest_teardown() • pytest_addoption()
  21. pytest - plugins http://pytest-plugs.herokuapp.com/

  22. Thank You! https://webtest.readthedocs.org/en/latest/ http://pytest.org/latest/contents.html http://pythontesting.net/