コード例 #1
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
    def test_expect_not_to_raise_error_can_take_callable_with_args(self):
        class SpecialException(Exception):
            pass

        argument = object()

        def callable_(x):
            if not x is argument:
                raise SpecialException('foo')

        expect(callable_, argument).not_to(raise_error(SpecialException))
コード例 #2
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
    def test_expect_not_to_raise_error_can_take_callable_with_args(self):
        class SpecialException(Exception):
            pass

        argument = object()

        def callable_(x):
            if not x is argument:
                raise SpecialException('foo')

        expect(callable_, argument).not_to(raise_error(SpecialException))
コード例 #3
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
    def test_expect_to_raise_error_can_take_callable_with_arg_and_kwargs(self):
        class SpecialException(Exception):
            pass

        argument = object()
        kwargs = dict(x=argument)

        def callable_(arg, x=None):
            if arg is argument and x is argument:
                raise SpecialException('foo')

        expect(callable_, argument, **kwargs).to(raise_error(SpecialException))
コード例 #4
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
    def test_expect_to_raise_error_can_take_callable_with_arg_and_kwargs(self):
        class SpecialException(Exception):
            pass

        argument = object()
        kwargs = dict(x=argument)

        def callable_(arg, x=None):
            if arg is argument and x is argument:
                raise SpecialException('foo')

        expect(callable_, argument, **kwargs).to(raise_error(SpecialException))
コード例 #5
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_greater_than_with_greater_value(self):
     expect(2).to(be_gt(1))
コード例 #6
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_less_than_with_greater_value(self):
     expect(1).to(be_lt(2))
コード例 #7
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_not_greater_than_with_lesser_value(self):
     expect(0).not_to(be_gt(1))
コード例 #8
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_to_be_with_non_identical_object(self):
     obj = object()
     other_obj = object()
     self.assertRaises(ExpectationNotMetError,
                       expect(obj).to, be(other_obj))
コード例 #9
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_member_to_be_in_list(self):
     expect(['foo', 'bar', 'baz']).to(include('foo', 'baz'))
コード例 #10
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_empty_string_to_be_falsy(self):
     expect('').to(be_falsy())
コード例 #11
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_less_than_or_equal_with_greater_value(self):
     expect(1).to(be_lte(2))
コード例 #12
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_be_within_3_of_0(self):
     expect(2).to(be_within(3).of(0))
コード例 #13
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_not_less_than_with_lesser_value(self):
     expect(1).not_to(be_lt(0))
コード例 #14
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_greater_than_or_equal_with_lesser_value(self):
     expect(2).to(be_gte(1))
コード例 #15
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_not_less_than_with_greater_value(self):
     self.assertRaises(ExpectationNotMetError, expect(1).not_to, be_lt(2))
コード例 #16
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_less_than_with_lesser_value(self):
     self.assertRaises(ExpectationNotMetError, expect(1).to, be_lt(0))
コード例 #17
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_less_than_with_greater_value(self):
     expect(1).to(be_lt(2))
コード例 #18
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_not_less_than_with_greater_value(self):
     self.assertRaises(ExpectationNotMetError, expect(1).not_to, be_lt(2))
コード例 #19
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_be_within_3_of_0(self):
     expect(2).to(be_within(3).of(0))
コード例 #20
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_greater_than_or_equal_with_lesser_value(self):
     expect(2).to(be_gte(1))
コード例 #21
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_string_to_match_pattern(self):
     expect('foobar').to(match(r'^[a-z]{6}$'))
コード例 #22
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_string_to_be_an_instance_of_str(self):
     expect('foobar').to(be_an_instance_of(str))
コード例 #23
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_string_to_be_an_instance_of_str(self):
     expect('foobar').to(be_an_instance_of(str))
コード例 #24
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_string_to_be_truthy(self):
     expect('foo').to(be_truthy())
コード例 #25
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_string_be_of_type_str(self):
     expect('foobar').to(be_of_type(str))
コード例 #26
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_pop_from_empty_list_to_raise_IndexError(self):
     expect([].pop).to(raise_error(IndexError))
コード例 #27
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_member_to_be_in_list(self):
     expect(['foo', 'bar', 'baz']).to(include('foo', 'baz'))
コード例 #28
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_not_to_be_with_identical_object(self):
     obj = object()
     same_obj = obj
     self.assertRaises(ExpectationNotMetError,
                       expect(obj).not_to, be(same_obj))
コード例 #29
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_something_not_to_be_in_list(self):
     expect(['foo', 'bar']).not_to(include('baz'))
コード例 #30
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_not_to_be_with_non_identical_object(self):
     obj = object()
     other_obj = object()
     expect(obj).not_to(be(other_obj))
コード例 #31
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_string_to_be_truthy(self):
     expect('foo').to(be_truthy())
コード例 #32
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_not_greater_than_with_lesser_value(self):
     expect(0).not_to(be_gt(1))
コード例 #33
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_empty_string_not_to_be_truthy(self):
     expect('').not_to(be_truthy())
コード例 #34
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_less_than_with_lesser_value(self):
     self.assertRaises(ExpectationNotMetError, expect(1).to, be_lt(0))
コード例 #35
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_empty_string_to_be_falsy(self):
     expect('').to(be_falsy())
コード例 #36
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_not_less_than_with_lesser_value(self):
     expect(1).not_to(be_lt(0))
コード例 #37
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_string_not_to_be_falsy(self):
     expect('foo').not_to(be_falsy())
コード例 #38
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_less_than_or_equal_with_greater_value(self):
     expect(1).to(be_lte(2))
コード例 #39
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_pop_from_empty_list_to_raise_IndexError(self):
     expect([].pop).to(raise_error(IndexError))
コード例 #40
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_string_to_match_pattern(self):
     expect('foobar').to(match(r'^[a-z]{6}$'))
コード例 #41
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_pop_from_list_not_to_raise_IndexError(self):
     expect([0].pop).not_to(raise_error(IndexError))
コード例 #42
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_string_be_of_type_str(self):
     expect('foobar').to(be_of_type(str))
コード例 #43
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_not_to_be_with_non_identical_object(self):
     obj = object()
     other_obj = object()
     expect(obj).not_to(be(other_obj))
コード例 #44
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_something_not_to_be_in_list(self):
     expect(['foo', 'bar']).not_to(include('baz'))
コード例 #45
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_to_be_with_non_identical_object(self):
     obj = object()
     other_obj = object()
     self.assertRaises(ExpectationNotMetError,
                       expect(obj).to, be(other_obj))
コード例 #46
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_empty_string_not_to_be_truthy(self):
     expect('').not_to(be_truthy())
コード例 #47
0
ファイル: red_spec.py プロジェクト: zhichen-wen/pyspec
from pyspec import description, specification
from pyspec.expectations import expect, eq

with description(True):
    with specification('is false'):
        expect(True).to(eq(False))
コード例 #48
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_string_not_to_be_falsy(self):
     expect('foo').not_to(be_falsy())
コード例 #49
0
ファイル: green_spec.py プロジェクト: zhichen-wen/pyspec
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))
コード例 #50
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_pop_from_list_not_to_raise_IndexError(self):
     expect([0].pop).not_to(raise_error(IndexError))
コード例 #51
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_greater_than_with_greater_value(self):
     expect(2).to(be_gt(1))
コード例 #52
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'):
コード例 #53
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_to_be_with_identical_object(self):
     obj = object()
     same_obj = obj
     expect(obj).to(be(same_obj))
コード例 #54
0
ファイル: broken_spec.py プロジェクト: zhichen-wen/pyspec
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))
コード例 #55
0
ファイル: matchers.py プロジェクト: zacstewart/pyspec
 def test_expect_not_to_be_with_identical_object(self):
     obj = object()
     same_obj = obj
     self.assertRaises(ExpectationNotMetError,
                       expect(obj).not_to, be(same_obj))
コード例 #56
0
ファイル: example_spec.py プロジェクト: zacstewart/pyspec
    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'):
コード例 #57
0
ファイル: matchers.py プロジェクト: zhichen-wen/pyspec
 def test_expect_to_be_with_identical_object(self):
     obj = object()
     same_obj = obj
     expect(obj).to(be(same_obj))