Giter VIP home page Giter VIP logo

python-proboscis's Introduction

Proboscis

Proboscis is a Python test framework that extends Python's built-in unittest module and Nose with features from TestNG.

Click here to read the full docs.

Features

  • Uses decorators instead of naming conventions.
  • Allows for TestNG style test methods, in which a class is initialized once, as an alternative to using class fields (see the example below).
  • Allows for explicit test dependencies and skipping of dependent tests on failures.
  • Runs xUnit style clases if desired or needed for backwards compatability.
  • Uses Nose if available (but doesn't require it), and works with many of its plugins.
  • Runs in IronPython and Jython (although if you're targetting the JVM you should consider using TestNG instead)!

Updates

Version 1.2.5.2

  • Fixed a bug that prevented some Nose plugins from working.

Version 1.2.5.1

  • Implemented test decorator property "runs_after", which affects only the order of test runs. If a test noted by "runs_after" fails, the test method or class targeted by the decorator will not be skipped. If a group is run, tests which are listed in "runs_after" will not implicitly be run as well.
  • Added 'fail' method to Checker class.
  • Using tox discovered some issues with Jython compatability.

Version 1.2.4

  • Added a missing parameter to a format string error message.
  • Fixed bug where the enabled property was not being inherited by class methods.
  • Added a Check class to allow testing multiple assertions in a with block.

Example

This example tests an external web service by creating an admin user and updating the profile picture.

@test(groups=["service.initialization"])
def make_sure_service_is_up():
    # No point in proceeding if the service isn't responding.
    assert_true(service_module.ping(service_config))


@test(groups=["service.tests"], depends_on_groups=["service.initialization"])
class AdminTest(object):

    @before_class
    def create_admin_user(self):
        self.client = service_module.ServiceClient(service_config)
        self.admin = self.client.create_admin_user("boss")

    @test
    def check_for_defaults(self):
        assert_equals("default.jpg", self.admin.get_profile_image())

    @test(depends_on=check_for_defaults)
    def change_picture(self):
        self.admin.set_profile_image("spam.jpg")
        assert_equals("spam.jpg", self.admin.get_profile_image())

    # Put other tests against admin user here...

    @after_class
    def destroy_admin_user(self):
        self.client.delete_user(self.admin)

Here, the variable "admin" is created only once, similar to TestNG.

If the xUnit style is preferred or needed for backwards compatability the following code will create the admin variable once for each test function:

@test(groups=["service.tests"], depends_on_groups=["service.initialization"])
class AdminTest(unittest.TestCase):

    def setUp(self):
        self.client = service_module.ServiceClient(service_config)
        self.admin = self.client.create_admin_user("boss")

    def test_change_picture(self):
        assert_equals("default.jpg", self.admin.get_profile_image())
        self.admin.set_profile_image("spam.jpg")
        assert_equals("spam.jpg", self.admin.get_profile_image())

    # Put other tests against admin user here...

    def tearDown(self):
        self.client.delete_user(self.admin)

Though this version of AdminTest runs like an xUnit test, it still runs after the "service.initialization" group.

For more info see the full docs.

python-proboscis's People

Watchers

 avatar  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.