class StrMock(Spec): def before(self): self.m = Mock() def should_allow_hook_expectations(self): self.m.should_access.__add__(self.m, "bar").and_return("foobar") Value(self.m + "bar").should == "foobar" def should_allow_sequence_hook_expectations(self): self.m.should_access.__contains__(self.m, "c").and_return(True) Value(self.m).should.contain("c") def should_allow_mock_verify_expectation(self): self.m.should_access.verify().and_return("bar") Value(self.m.mock).invoking.verify().should == "bar" @fails_verification def should_mock_verification(self): self.m.should_access.upper().and_return("FOO") def should_mock_with_no_args(self): self.m.should_access.upper().and_return("FOO") Value(self.m).invoking.upper().should == "FOO" def should_mock_with_no_access(self): self.m.should_not_access.upper() self.m.lower() def should_mock_with_one_specific_arg(self): self.m.should_access.rjust(5).and_return(" " * 5) Value(self.m).invoking.rjust(5).should == " " @fails_verification def should_mock_invalid_args(self): self.m.should_access.rjust(5).and_return(" " * 5) self.m.rjust(3) def should_raise_error_on_add_numbers(self): self.m.should_access.__add__(self.m, 3).and_raise(ValueError) (Value(self.m) + 3).should.raise_error(ValueError)