background preloader

Testing

Facebook Twitter

Mamba: the definitive test runner for Python. Mamba is the definitive test runner for Python.

mamba: the definitive test runner for Python

Born under the banner of behavior-driven development. Install I recommend to use pipenv for managing your dependencies, thus you can install mamba like any other Python package. By example: But you also can use pip: Getting Started Write a very simple example that describes your code behaviour: # tennis_spec.py from mamba import description, context, it from expects import expect, equal with description('Tennis') as self: with it('starts with 0 - 0 score'): rafa_nadal = "Rafa Nadal" roger_federer = "Roger Federer" game = Game(rafa_nadal, roger_federer) expect(game.score()).to(equal((0, 0))) Run the example, and don’t forget to watch it fail!

Now write as little code for making it pass. # tennis.py class Game(object): def __init__(self, player1, player2): pass def score(self): return (0, 0) Run the spec file and enjoy that all tests are green! Mamba — mamba 0.9.2 documentation. Welcome to Hypothesis! — Hypothesis 5.8.0 documentation. Welcome to Hypothesis! — Hypothesis 5.6.0 documentation. Rollbar - Error Tracking Software for Ruby, Python, JavaScript, more. Pytest-nodev — test-driven code search.

Pytest documentation. Good Integration Practises. Work with virtual environments We recommend to use virtualenv environments and use pip (or easy_install) for installing your application and any dependencies as well as the pytest package itself.

Good Integration Practises

This way you will get an isolated and reproducible environment. Given you have installed virtualenv and execute it from the command line, here is an example session for unix or windows: virtualenv . # create a virtualenv directory in the current directory source bin/activate # on unix scripts/activate # on Windows We can now install pytest: Due to the activate step above the pip will come from the virtualenv directory and install any package into the isolated virtual environment. FitNesse. FitNesse is a web server, a wiki, and an automated testing tool for software.

FitNesse

It is based on Ward Cunningham's Framework for Integrated Test. FitNesse is designed to support acceptance testing rather than unit testing in that it facilitates detailed readable description of system function. FitNesse allows users of a developed system to enter specially formatted input (its format is accessible to non-programmers). This input is interpreted and tests are created automatically. These tests are then executed by the system and output is returned to the user. Principles of FitNesse[edit] FitNesse as a testing method[edit] FitNesse was originally designed as a highly usable interface around the Fit framework.

FitNesse testing is based around the notion of black-box testing, in which a system under test is considered to be a black box and is tested in terms of the outputs generated in response to predetermined inputs. Introduction — Lettuce v0.1rc11 (barium release) documentation. Lets begin to describe and solve our problem... first round [a] describe behaviour Start describing the expected behaviour of factorial in zero.feature using English: Feature: Compute factorial In order to play with Lettuce As beginners We’ll implement factorial Scenario: Factorial of 0 Given I have the number 0 When I compute its factorial Then I see the number 1 Note.

introduction — Lettuce v0.1rc11 (barium release) documentation

Garybernhardt/expecter. Tl;dw: Speedily practical large-scale tests. At PyCon 2012, Erik Rose gave a talk entitled, Speedily Practical Large-Scale Tests.

tl;dw: Speedily practical large-scale tests

This is my textual summary of the talk, one of a series of summaries. Here's the video of Erik: For those in too much of a hurry to even read the text here, the tl;dr: Slow test suites are usually slow due to I/O. Erik reduced test fixture I/O by moving fixture setup and teardown to the class instead of the tests, by rearranging classes to reuse fixtures, and by removing fixtures in favor of constructed objects. This was a long (40 minute) talk, and Erik covered a number of points, I hope I captured it. I work at Mozilla, we have lots of large web services to keep running, some with 30 billion requests a month. First I'll cover how to make the tests fast, then how to keep them maintainable, then how to make them as informative as possible. The sumo project has really clean code, but the tests are really slow. Plone.testing 4.0.7. Testing infrastructure for Zope and Plone projects.

plone.testing 4.0.7

To use plone.testing in your own package, you need to add it as a dependency. Most people prefer to keep test-only dependencies separate, so that they do not need to be installed in scenarios (such as on a production server) where the tests will not be run. This can be achieved using a test extra. In setup.py, add or modify the extras_require option, like so: Pytest - rapid and simple testing with Python.

TestingToolsTaxonomy. Join the Testing In Python (TIP) mailing list for Python testing tools discussions!

TestingToolsTaxonomy

This wiki page is originated from PyCheeseCake and it was originally created by Grig Gheorghiu Unit Testing Tools The following tools are not currently being developed or maintained as far as we can see. They are here for completeness, with last activity date and an indication of what documentation there is. If you know better, please edit. Mock Testing Tools See also here for a side-by-side syntax comparison between some of the more popular tools in this space.

Unittest

Testing Tools for Python - Doug Hellmann. Test Driven Development and Test Automation are all the rage, and Python developers have no shortage of tools for testing their own applications.

Testing Tools for Python - Doug Hellmann

This month I am starting a series of columns on tools for developing in Python. I intend to cover areas such as version control, utility modules, build, and packaging tools. Eventually I may even work up the courage to address the issue of editors and IDEs while, I hope, avoiding a religious war. But let’s start out by looking at tools for testing your libraries and applications. This isn’t a comprehensive survey, but it should give you some idea of the kinds of tools available.