Giter Site home page Giter Site logo

intro-to-pytest's Introduction

intro-to-pytest

An introduction to PyTest with lots of simple, hackable examples (currently Python 2.7 / 3.6+ compatible).

These examples are intended to be self-explanatory to a Python developer, with minimal setup - In addition to Python 2.7 or 3.6+, you'll also need pytest and the pytest-mock plugin installed to use all these examples, which you can install by running:

pip install -r requirements.txt

In this folder (ideally, inside a virtual environment, to keep this from affecting your local Python libraries).

Once you've got all the requirements in place, you should be able to simply run

pytest

In this folder, and see 109 items being collected, and 109 tests passing, in each of the example files, in less than a second.

(PyTest will list the names of each test module file that it found, and then a period for each test case that passed, or other symbols for tests that failed, were skipped, etc.)

But if you're seeing all that, congratulations! You're ready to get started.

The recommended approach is to read each example file, then run it directly with pytest, with the v flag (so that each Test Case is listed "verbosely", by name) and the s flag, so that we can all the standard output (prints) from the Tests, which will help explain how each example is working; PyTest normally captures and hides this output, except for tests that are currently failing. (In the examples below, we'll shorten these arguements to -vs.)

Each example test was intended to be self-explanatory, but I have begun adding short tutorial guides to explain more of the context, suggest experiments and hacks you can attempt on th examples, and to provide recaps and reviews for each major section. The tutorial track starts with:

Tutorial Zero: An Empty Test

Not all of the examples have an accompanying tutorial (yet), but were written to be self-explanatory, and should at least include basic comments to explain the feature being demonstrated.

If you have any feedback, questions, or PyTest features you'd like to see covered, please let me know on Pluralsight Slack as @david.sturgis, or via email at [email protected], or via GitHub Issues (or a PR, now that I have PR notifcations turned on!).

intro-to-pytest's People

Contributors

tenth10th avatar hwong557 avatar jss367 avatar pamamu avatar sk8asd123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.