Example #1
0
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])
Example #2
0
 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]])
Example #3
0
 def test_reduce_right(self):
     result = self.sample.reduce_right(lambda t, x: t + x)._
     the(result).should.equal(45)
Example #4
0
 def test_each(self):
     r = []
     self.sample.each(lambda x: r.append(x))
     the(self.sample.value()).should.equal(r)
Example #5
0
 def test_new(self):
     fake = copy.deepcopy(self.sample)
     the(fake.value()).should.equal(self.sample.value())
     the(fake).should.NOT.equal(self.sample)
Example #6
0
 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())
Example #7
0
 def test_be_callable(self):
     self.assertTrue(the(1).be(1))
     with self.assertRaises(AssertionError):
         the(True).should.be(False)
Example #8
0
 def test_pluck(self):
     the(self.sample2.pluck("b").list().value()).should.be.equal([2, 2])
Example #9
0
 def test_map(self):
     result = self.sample.map(lambda x: x+1).list().value()
     the(result).should.equal(list(range(1,11)))
Example #10
0
 def test_each(self):
     r = []
     self.sample.each(lambda x: r.append(x))
     the(self.sample.value()).should.equal(r)
Example #11
0
 def test_value(self):
     the(self.sample.value).when.apply().should.have.result(list(range(10)))
Example #12
0
 def test_new(self):
     fake = copy.deepcopy(self.sample)
     the(fake.value()).should.equal(self.sample.value())
     the(fake).should.NOT.equal(self.sample)
Example #13
0
 def test_setitem(self):
     s = self.sample.list()
     the(s[0]).should.equal(0)
     s[0] = 1
     the(s[0]).should.equal(1)
Example #14
0
 def test_getitem(self):
     the(self.sample[0]).should.equal(0)
Example #15
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)))
Example #16
0
 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
Example #17
0
 def test_reduce_right(self):
     result = self.sample.reduce_right(lambda t, x: t+x)._
     the(result).should.equal(45)
Example #18
0
 def test_min(self):
     the(self.sample.min()._).should.be(0)
     the(self.sample.min(lambda x: -x)._).should.be(9)
Example #19
0
 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
Example #20
0
 def test_a_callable(self):
     self.assertTrue(the("1").should.be.a(str))
     with self.assertRaises(AssertionError):
         the(1).should.be.a(str)
Example #21
0
 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]])
Example #22
0
 def test_setitem(self):
     s = self.sample.list()
     the(s[0]).should.equal(0)
     s[0] = 1
     the(s[0]).should.equal(1)
Example #23
0
 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])
Example #24
0
 def test_value(self):
     the(self.sample.value).when.apply().should.have.result(list(range(10)))
Example #25
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)))
Example #26
0
 def test_map(self):
     result = self.sample.map(lambda x: x + 1).list().value()
     the(result).should.equal(list(range(1, 11)))
Example #27
0
 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
Example #28
0
 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
Example #29
0
 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
Example #30
0
 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])
Example #31
0
 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)
Example #32
0
 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
Example #33
0
 def test_pluck(self):
     the(self.sample2.pluck("b").list().value()).should.be.equal([2,2])
Example #34
0
 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)
Example #35
0
 def test_max(self):
     the(self.sample.max()._).should.be.equal(9)
     the(self.sample.max(lambda x: -x)._).should.be.equal(0)
Example #36
0
 def test_max(self):
     the(self.sample.max()._).should.be.equal(9)
     the(self.sample.max(lambda x: -x)._).should.be.equal(0)
Example #37
0
 def test_min(self):
     the(self.sample.min()._).should.be(0)
     the(self.sample.min(lambda x: -x)._).should.be(9)
Example #38
0
 def test_reverse(self):
     the(self.sample.reverse().value()).should.equal(list(range(9, -1, -1)))
Example #39
0
 def test_reverse(self):
     the(self.sample.reverse().value()).should.equal(list(range(9, -1, -1)))
Example #40
0
 def test_the_a(self):
     it = the(1)
     self.assertTrue(isinstance(it.a, _TheA))
     self.assertEqual(it.a.should, it)
Example #41
0
 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())
Example #42
0
 def test_the_be(self):
     it = the(1)
     self.assertTrue(isinstance(it.be, _TheBe))
     self.assertEqual(it.be.should, it)
Example #43
0
 def test_getitem(self):
     the(self.sample[0]).should.equal(0)