def step_impl(context, solution): """ :type solution: str """ parsed_ops = parse_operations(solution) print(context.solution) print(parsed_ops) the(parsed_ops).should.have.length(len(context.solution)) for i in range(len(context.solution)): the(context.solution[i]).should.equal(parsed_ops[i])
def test_where(self): result = self.sample2.where({"b": 2}).list().value() the(result).should.equal(self.sample2.value()) result = self.sample2.where({"a": 1}).list().value() the(result).should.equal([self.sample2.value()[0]])
def test_reduce_right(self): result = self.sample.reduce_right(lambda t, x: t + x)._ the(result).should.equal(45)
def test_each(self): r = [] self.sample.each(lambda x: r.append(x)) the(self.sample.value()).should.equal(r)
def test_new(self): fake = copy.deepcopy(self.sample) the(fake.value()).should.equal(self.sample.value()) the(fake).should.NOT.equal(self.sample)
def test_sort_by(self): t = self.sample.deep_copy() result = self.sample.sort_by(key=lambda x: -x).value() the(result).should.equal(t.reverse().value())
def test_be_callable(self): self.assertTrue(the(1).be(1)) with self.assertRaises(AssertionError): the(True).should.be(False)
def test_pluck(self): the(self.sample2.pluck("b").list().value()).should.be.equal([2, 2])
def test_map(self): result = self.sample.map(lambda x: x+1).list().value() the(result).should.equal(list(range(1,11)))
def test_value(self): the(self.sample.value).when.apply().should.have.result(list(range(10)))
def test_setitem(self): s = self.sample.list() the(s[0]).should.equal(0) s[0] = 1 the(s[0]).should.equal(1)
def test_getitem(self): the(self.sample[0]).should.equal(0)
def test_reject(self): result = self.sample.filter(lambda x: x % 2 == 1).list().value() the(result).should.equal(list(range(1, 10, 2)))
def test_some(self): the(self.sample.some(lambda x: x > 4)).should.be.true the(self.sample.some(lambda x: x > 10)).should.be.false
def test_reduce_right(self): result = self.sample.reduce_right(lambda t, x: t+x)._ the(result).should.equal(45)
def test_min(self): the(self.sample.min()._).should.be(0) the(self.sample.min(lambda x: -x)._).should.be(9)
def test_find_item(self): result = self.sample.find_item(lambda x: x == 5)._ the(result).should.equal(5) result = self.sample.find_item(lambda x: x == 11) the(result).should.be.none
def test_a_callable(self): self.assertTrue(the("1").should.be.a(str)) with self.assertRaises(AssertionError): the(1).should.be.a(str)
def test_find_where(self): result = self.sample2.find_where({"b": 2}).value() the(result).should.equal(self.sample2.value()[0]) result = self.sample2.find_where({"a": 1}).value() the(result).should.equal(self.sample2.value()[0])
def test_reject(self): result = self.sample.filter(lambda x: x%2==1).list().value() the(result).should.equal(list(range(1,10,2)))
def test_map(self): result = self.sample.map(lambda x: x + 1).list().value() the(result).should.equal(list(range(1, 11)))
def test_all(self): the(self.sample.all(lambda x: x > -1)).should.be.true the(self.sample.all(lambda x: x > 1)).should.be.false
def test_contains(self): the(self.sample.contains).when.apply(2).should.have.result(True) the(self.sample.contains).when.apply(121).should.have.result(False)
def test_pluck(self): the(self.sample2.pluck("b").list().value()).should.be.equal([2,2])
def test_max(self): the(self.sample.max()._).should.be.equal(9) the(self.sample.max(lambda x: -x)._).should.be.equal(0)
def test_reverse(self): the(self.sample.reverse().value()).should.equal(list(range(9, -1, -1)))
def test_the_a(self): it = the(1) self.assertTrue(isinstance(it.a, _TheA)) self.assertEqual(it.a.should, it)
def test_the_be(self): it = the(1) self.assertTrue(isinstance(it.be, _TheBe)) self.assertEqual(it.be.should, it)