def __repr__(self): message = 'have been called' if self._args or self._kwargs: message += ' with {}'.format(plain_enumerate(self._args, self._kwargs)) if len(self._times_description) != 0: message += ' ' + self._times_description return message
def __repr__(self): message = 'have been called' if self._args or self._kwargs: message += ' with {}'.format( plain_enumerate(self._args, self._kwargs)) if len(self._times_description) != 0: message += ' ' + self._times_description return message
def _description(self, subject): message = 'have been called' if self._args or self._kwargs: message += ' with {}'.format(plain_enumerate(self._args, self._kwargs)) if len(self._times_description) != 0: message += ' ' + self._times_description message += ' but calls that actually ocurred were:\n{}'.format(subject.double._recorded.show(indent=10)) return message
# -*- coding: utf-8 -*- from expects import * from expects.texts import plain_enumerate with describe('plain_enumerate'): with context('with one arg'): with it('returns repr of arg'): result = plain_enumerate(('foo',)) expect(result).to(equal("'foo'")) with context('with two args'): with it('returns repr of args joined by "and"'): result = plain_enumerate(('foo', 'bar')) expect(result).to(equal("'foo' and 'bar'")) with context('with three args'): with it('returns repr of args joined by "," and "and"'): result = plain_enumerate(('foo', 'bar', 'baz')) expect(result).to(equal("'foo', 'bar' and 'baz'")) with context('with one arg and one kwarg'): with it('returns repr of arg and kwarg joined by "and"'): result = plain_enumerate(('foo',), {'a': 0}) expect(result).to(equal("'foo' and 'a' equal 0"))
with it('passes if called with keyword args matching matchers'): self.method(**self.kwargs) expect(self.method).to(have_been_called_with( **{k: be_a(type(v)) for k,v in self.kwargs.items()})) with it('should fail if not called with positional arg'): self.method() with failure('to have been called with {!r}'.format(self.arg1)): expect(self.method).to(have_been_called_with(self.arg1)) with it('should fail if not called with keyword args'): self.method() with failure('been called with {}'.format(plain_enumerate((), self.kwargs))): expect(self.method).to(have_been_called_with(**self.kwargs)) with context('#negated'): with it('should pass if called with different positional arg'): self.method(self.arg1) expect(self.method).not_to(have_been_called_with(self.arg1, self.arg2)) with it('should fail if called with args'): self.method(self.arg1, **self.kwargs) with failure('not to have been called with {}'.format(plain_enumerate((self.arg1,), self.kwargs))): expect(self.method).not_to(have_been_called_with(self.arg1, **self.kwargs)) with describe('once'):
# -*- coding: utf-8 -*- from expects import * from expects.texts import plain_enumerate with describe('plain_enumerate'): with context('with one arg'): with it('returns repr of arg'): result = plain_enumerate(('foo', )) expect(result).to(equal("'foo'")) with context('with two args'): with it('returns repr of args joined by "and"'): result = plain_enumerate(('foo', 'bar')) expect(result).to(equal("'foo' and 'bar'")) with context('with three args'): with it('returns repr of args joined by "," and "and"'): result = plain_enumerate(('foo', 'bar', 'baz')) expect(result).to(equal("'foo', 'bar' and 'baz'")) with context('with one arg and one kwarg'): with it('returns repr of arg and kwarg joined by "and"'): result = plain_enumerate(('foo', ), {'a': 0}) expect(result).to(equal("'foo' and 'a' equal 0")) with context('with three args and three kwargs'):
# -*- coding: utf-8 -*- from expects import * from expects.texts import plain_enumerate with describe('plain_enumerate'): with context('one arg'): with it('returns repr of arg'): result = plain_enumerate(('foo',)) expect(result).to(equal("'foo'")) with context('two args'): with it('returns repr of args'): result = plain_enumerate(('foo', 'bar')) expect(result).to(equal("'foo' and 'bar'")) with context('three args'): with it('returns repr of args'): result = plain_enumerate(('foo', 'bar', 'baz')) expect(result).to(equal("'foo', 'bar' and 'baz'")) with context('one arg and one kwarg'): with it('returns repr of args and kwargs'): result = plain_enumerate(('foo',), {'a': 0}) expect(result).to(equal("'foo' and 'a' equal 0"))