Ejemplo n.º 1
0
    def testGenerateFactsDefaultsThirtyFacts(self):
        high = 12
        low = 0
        
        results = facts.generatefacts(low, high)

        self.assertEquals(30,len(results))
Ejemplo n.º 2
0
 def genfacts(self, low=0, high=12, amount=30, op=''):
     fs = facts.generatefacts(int(low),int(high),int(amount),op)
     latex.buildlatexfile(fs)
     filename = 'arithmetic.pdf'
     call('pdflatex arithmetic.tex', shell=True)
     returnfile = open(filename,'rb')
     return serve_fileobj(returnfile,disposition='attachment',
                          content_type='application/pdf',name=filename)
Ejemplo n.º 3
0
 def genfacts(self, low=0, high=12, amount=30, op=''):
     fs = facts.generatefacts(int(low), int(high), int(amount), op)
     latex.buildlatexfile(fs)
     filename = 'arithmetic.pdf'
     call('pdflatex arithmetic.tex', shell=True)
     returnfile = open(filename, 'rb')
     return serve_fileobj(returnfile,
                          disposition='attachment',
                          content_type='application/pdf',
                          name=filename)
Ejemplo n.º 4
0
    def testGenerateFactsDefaultsToZeroToTwelve(self):
        high = 12
        low = 0
        amount = 500
        
        results = facts.generatefacts(low, high, amount)

        for fact in results:
            self.assertTrue(low <= fact.left <= high)
            self.assertTrue(low <= fact.right <= high)
Ejemplo n.º 5
0
    def testGenerateFactsStaysWithinLimits(self):
        high = 15
        low = 2
        amount = 500
        
        results = facts.generatefacts(low, high, amount)

        for fact in results:
            self.assertTrue(low <= fact.left <= high)
            self.assertTrue(low <= fact.right <= high)
Ejemplo n.º 6
0
    def testGenerateFactsCanGiveMixOfPlusMinus(self):
        results = facts.generatefacts(amount=500)

        pluscount = 0
        minuscount = 0
        for fact in results:
            if fact.sign == '+':
                pluscount += 1
            elif fact.sign == '-':
                minuscount += 1
            else:
                self.assertFalse(True)
        self.assertEquals(500,pluscount+minuscount)
        self.assertTrue(200 < pluscount < 300)
Ejemplo n.º 7
0
    def testGenerateFactsCanGivePlus(self):
        results = facts.generatefacts(op='+')

        for fact in results:
            self.assertEquals('+',fact.sign)
Ejemplo n.º 8
0
    def testGenerateFactsYieldsNoNegatives(self):
        results = facts.generatefacts(amount=500, op='-')

        for fact in results:
            self.assertTrue(fact.result >= 0)