Example #1
0
from pyspec import description, specification
from pyspec.expectations import expect, eq

with description(True):
    with specification('is not false'):
        expect(True).not_to(eq(False))
Example #2
0
    def is_fizz(self, n):
        return n % 3 == 0

    def is_buzz(self, n):
        return n % 5 == 1

with description(BrokenFizzBuzz):

    fizzbuzz = BrokenFizzBuzz()
    some_integer = 7

    with description('.convert'):

        with context(15):
            with specification('returns fizzbuzz'):
                expect(fizzbuzz.convert(15)).to(eq('fizzbuzz'))

        with context(3):
            with specification('returns fizz'):
                expect(fizzbuzz.convert(3)).to(eq('fizz'))

        with context(5):
            with specification('returns buzz'):
                expect(fizzbuzz.convert(5)).to(eq('buzz'))

        with context('some other integer'):
            with specification('returns the integer'):
                expect(fizzbuzz.convert(some_integer)).to(
                    eq(some_integer))

    with description('.floop'):
Example #3
0
from pyspec import description, specification
from pyspec.expectations import expect, eq

with description(True):
    with specification('is false'):
        expect(True).to(eq(False))
Example #4
0
from pyspec import description, specification
from pyspec.expectations import expect, eq

with description(object):
    subject = object()
    with description('.foobar'):
        with specification('is not a thing'):
            expect(subject.foobar).to(eq(None))
Example #5
0
 def test_expect_equal_with_inequal_value(self):
     self.assertRaises(ExpectationNotMetError, expect(1).to, eq(2))
Example #6
0
 def test_expect_not_equal_with_inequal_value(self):
     expect(1).not_to(eq(2))
Example #7
0
 def test_expect_equal_with_equal_value(self):
     expect(1).to(eq(1))
Example #8
0
        return n % 3 == 0

    def is_buzz(self, n):
        return n % 5 == 1


with description(BrokenFizzBuzz):

    fizzbuzz = BrokenFizzBuzz()
    some_integer = 7

    with description('.convert'):

        with context(15):
            with specification('returns fizzbuzz'):
                expect(fizzbuzz.convert(15)).to(eq('fizzbuzz'))

        with context(3):
            with specification('returns fizz'):
                expect(fizzbuzz.convert(3)).to(eq('fizz'))

        with context(5):
            with specification('returns buzz'):
                expect(fizzbuzz.convert(5)).to(eq('buzz'))

        with context('some other integer'):
            with specification('returns the integer'):
                expect(fizzbuzz.convert(some_integer)).to(eq(some_integer))

    with description('.floop'):
        with specification('does not exist'):
Example #9
0
 def test_expect_not_equal_with_inequal_value(self):
     expect(1).not_to(eq(2))
Example #10
0
 def test_expect_equal_with_inequal_value(self):
     self.assertRaises(ExpectationNotMetError, expect(1).to, eq(2))
Example #11
0
 def test_expect_equal_with_equal_value(self):
     expect(1).to(eq(1))