コード例 #1
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
    def test_raises_incorrect_exception(self):
        def raise_():
            raise KeyError()

        with self.assertRaises(AssertionError):
            this(raise_).should.raise_a(IndexError)
        with self.assertRaises(AssertionError):
            this(raise_).should.raise_an(IndexError)
コード例 #2
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
    def test_raises_no_error(self):
        def no_error():
            pass

        with self.assertRaises(AssertionError):
            this(no_error).should.raise_a(Exception)
        with self.assertRaises(AssertionError):
            this(no_error).should.raise_an(Exception)
コード例 #3
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
    def test_raises_with_incorrect_error_message(self):
        def raise_():
            raise KeyError("Specific Error Message")

        with self.assertRaises(AssertionError):
            this(raise_).should.raise_a(KeyError, "Wrong Error Message")
        with self.assertRaises(AssertionError):
            this(raise_).should.raise_an(KeyError, "Wrong Error Message")
コード例 #4
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
    def test_decorate_with_custom_assertion(self):
        def be_5(this):
            this._assert(
                action=lambda: this._value == 5,
                report=lambda: "'{0}' should equal '5'.".format(this._value)
            )
        should_expectation(be_5)

        this(5).should.be_5()
        with self.assertRaises(AssertionError):
            this(4).should.be_5()
コード例 #5
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_be_in(self):
     this('f').should.be_in('foo')
コード例 #6
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_be_between(self):
     this(2).should.be_between(1, 3)
コード例 #7
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_be(self):
     this(True).should.be(True)
コード例 #8
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_be_less_than_or_equal_to(self):
     this(0).should.be_less_than_or_equal_to(0)
     this(-1).should.be_less_than_or_equal_to(0)
コード例 #9
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_should_be_less_than(self):
     with self.assertRaises(AssertionError) as e:
         this(1).should.be_less_than(0)
コード例 #10
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_should_be_greater_than(self):
     with self.assertRaises(AssertionError) as e:
         this(0).should.be_greater_than(1)
コード例 #11
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_empty(self):
     this(list()).should.be_empty()
     this(str()).should.be_empty()
     this(dict()).should.be_empty()
     this(tuple()).should.be_empty()
     this(set()).should.be_empty()
コード例 #12
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_when_not_equal(self):
     with self.assertRaises(AssertionError):
         this('foo').should.equal('bar')
コード例 #13
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
    def test_raises_with_correct_error_message(self):
        def raise_():
            raise KeyError("Message 123")

        this(raise_).should.raise_a(KeyError, "Message 123")
        this(raise_).should.raise_an(KeyError, "Message 123")
コード例 #14
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_when_equal(self):
     this('foo').should.equal('foo')
コード例 #15
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_should_be_in(self):
     with self.assertRaises(AssertionError) as e:
         this('x').should.be_in('foo')
コード例 #16
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_empty(self):
     with self.assertRaises(AssertionError):
         this('asdf').should.be_empty()
コード例 #17
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_be_greater_than(self):
     this(1).should.be_greater_than(0)
コード例 #18
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_NOT_inverts_assertion_logic(self):
     this('foo').should_not.equal('bar')
コード例 #19
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_be_less_than(self):
     this(0).should.be_less_than(1)
コード例 #20
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_NOT_embellishes_syntax_error(self):
     with self.assertRaises(AssertionError) as e:
         this('foo').equal('foo')
     self.assertEquals(PREPARATION_ERROR, str(e.exception))
コード例 #21
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_be_greater_than_or_equal_to(self):
     this(0).should.be_greater_than_or_equal_to(0)
     this(1).should.be_greater_than_or_equal_to(0)
コード例 #22
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
    def test_NOT_embellishes_error_message_on_failure_accordingly(self):
        with self.assertRaises(AssertionError) as e:
            this('foo').should_not.equal('foo')

        self.assertEquals("Expected 'foo' NOT to equal 'foo'.", str(e.exception))
コード例 #23
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_should_be_less_than_or_equal_to(self):
     with self.assertRaises(AssertionError) as e:
         this(0).should.be_less_than_or_equal_to(-1)
コード例 #24
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_be_a(self):
     this('foo').should.be_a(str)
コード例 #25
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_should_be(self):
     with self.assertRaises(AssertionError) as e:
         this(True).should.be(False)
コード例 #26
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_passing_should_contain(self):
     this('foo').should.contain('o')
コード例 #27
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
 def test_failing_be_between(self):
     with self.assertRaises(AssertionError) as e:
         this(1).should.be_between(2, 3)
コード例 #28
0
ファイル: test_should.py プロジェクト: mdwhatcott/pyspecs
    def test_raises_with_unspecified_message(self):
        def raise_():
            raise KeyError()

        this(raise_).should.raise_a(KeyError)
        this(raise_).should.raise_an(KeyError)