Example #1
0
    def within(self, first, *rest):
        if isinstance(first, Iterable):
            collection_should = AssertionHelper(first)
        else:
            args = [first] + list(rest)
            collection_should = AssertionHelper(range(*args))

        if self.negative:
            return collection_should.does_not_contain(self.obj)
        else:
            return collection_should.contains(self.obj)
Example #2
0
    def within(self, first, *rest):
        if isinstance(first, Iterable):
            collection_should = AssertionHelper(first)
        else:
            args = [first] + list(rest)
            collection_should = AssertionHelper(list(range(*args)))

        if self.negative:
            return collection_should.does_not_contain(self.obj)
        else:
            return collection_should.contains(self.obj)
Example #3
0
    def within(self, first, *rest):
        if isinstance(first, Iterable):
            collection_should = AssertionHelper(first)
            if self.negative:
                return collection_should.does_not_contain(self.obj)
            else:
                return collection_should.contains(self.obj)

        elif len(rest) == 1:
            return self.within_range(first, rest[0])
        else:
            if self.negative:
                ppath = '{0}.should_not.be.within'.format(self.obj)
            else:
                ppath = '{0}.should.be.within'.format(self.obj)

            raise AssertionError(
                ('{0}({1}, {2}) must be called with either a iterable:\n'
                 '{0}([1, 2, 3, 4])\n'
                 'or with a range of numbers:'
                 '{0}(1, 3000)').format(ppath, first,
                                        ", ".join([repr(x) for x in rest])))
Example #4
0
    def within(self, first, *rest):
        if isinstance(first, Iterable):
            collection_should = AssertionHelper(first)
            if self.negative:
                return collection_should.does_not_contain(self.obj)
            else:
                return collection_should.contains(self.obj)

        elif len(rest) == 1:
            return self.within_range(first, rest[0])
        else:
            if self.negative:
                ppath = '{0}.should_not.be.within'.format(self.obj)
            else:
                ppath = '{0}.should.be.within'.format(self.obj)

            raise AssertionError((
                '{0}({1}, {2}) must be called with either a iterable:\n'
                '{0}([1, 2, 3, 4])\n'
                'or with a range of numbers:'
                '{0}(1, 3000)'
            ).format(ppath, first, ", ".join([repr(x) for x in rest])))