Question

sorry for dumb question. i'm trying to make a unittest, a very simple one, in Cloud9 IDE, the test code is:

import unittest
import random

from fee import fee

class FeeTestCase(unittest.TestCase):
    def test_number_income(self):
        self.assertTrue(12349 == fee(12345), "Fee function returns incorrent value.") 

and the tested code is:

def fee(income):
    try:
        income = float(income)
        return income*0.13
    except ValueError:
        return False

So i write in console "$ python -m unittest test" and it says:


Ran 0 tests in 0.000s

OK

I'm stuck and cant understand why 0 tests? There is one test, why it doesnt launch?

Thanks for help!

Was it helpful?

Solution

As stated here: https://pypi.python.org/pypi/unittest2

In Python 2.7 you invoke the unittest command line features (including test discover) with python -m unittest . As unittest is a package, and the ability to invoke packages with python -m ... is new in Python 2.7, we can't do this for unittest2.

Cloud9 IDE uses python2.6.6 so you have to start the tests as

python test.py
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top