Skip to main content

No project description provided

Project description

Pyne Testing Framework

Pyne is a BDD style testing framework for Python. It's styled after frameworks for other languages like Mocha, Jasmine, Spectrum, and Rspec.

An example pyne test:

@pyne
def some_file():
    @describe("when two numbers are added together")
    def _():
      @before_each
      def _(self):
        self.calculator = Calculator()

      @it("returns the sum")
      def _(self):
        expect(self.calculator.calculate("22 + 11")).to_be(33)

You can see more examples in the examples folder

Running tests

Run a file

python some_test.py

Run all tests

To run all the tests in a directory, you can use the cli:

./pyne/cli.py

Run only some tests

You can focus on a single test by using @fit instead of @it Or a single describe block by using @fdescribe instead of @describe

Using Test Doubles

Spying

In order to spy on an instances methods:

from pyne.expectations import expect
from pyne.pyne_test_collector import before_each, describe, it
from pyne.test_doubles.spy import stub

from some_module import SomeClass

@describe("SomeClass")
def _():
    @before_each
    def _(self):
        self.class_instance = SomeClass()
        stub(self.class_instance, self.class_instance.some_method)
    
    @it("gets called with something")
    def _(self):
        self.class_instance.some_method("something")
        expect(self.class_instance.some_method).was_called_with("something")

If you need the method to still return something, you scan specify what it returns:

    @before_each
    def _(self):
        self.class_instance = SomeClass()
        stub(self.class_instance, self.class_instance.some_method)
        self.class_instance.some_method.returns("some value")

Contribution / Development

For instructions on how to contribute to Pyne, read CONTRIBUTING.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynetest-0.2.24.tar.gz (52.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynetest-0.2.24-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file pynetest-0.2.24.tar.gz.

File metadata

  • Download URL: pynetest-0.2.24.tar.gz
  • Upload date:
  • Size: 52.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for pynetest-0.2.24.tar.gz
Algorithm Hash digest
SHA256 c2319f3440537ac8142744140c8b11b5e756839cbfb72ea1a7eab4184c2e8647
MD5 c5d750c2171afca39707f7b6ba56a28c
BLAKE2b-256 ca42abd956086b9d10aa51511128541a121ee2f0ee05e98ea41a6a9705e90af3

See more details on using hashes here.

File details

Details for the file pynetest-0.2.24-py3-none-any.whl.

File metadata

  • Download URL: pynetest-0.2.24-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for pynetest-0.2.24-py3-none-any.whl
Algorithm Hash digest
SHA256 9bdf73a5440de20f8510e39b4d07e87cf6d1cf636c919fde9add50a5da9602e9
MD5 a11b557990182437434a5f89ae52b459
BLAKE2b-256 f0bcf1da06da59392bbf7ecacc53e1ac3c20bf2dc1ea80486acbd534d0b69998

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page