简体   繁体   中英

Python unitest doesn't run test functions from PythonAnywhere

I'm having a problem with unittest testing, code and results below.

I try to run my test from the PythonAnywhere IDE, and it says that 0 test has been made.

I tested the code with prints to find out where things went wrong and I found out that interpreter doesn't even go into the function to see the test. I know the test names should start with "test_", which they do. Any other idea?

I am working on pythonAnywhere if it's matter somehow.

My code:

import unittest
import signUpForm

class Test_signUp(unittest.TestCase):

    print ("i got to here")
    def test_Utility(self):
        print ("but never here")
        # test all utlity functions in the sign up form. and delete the changes afterward
        #check system addition and manipulation
        self.assertEqual(addSystem ("dungeons" , 8000) , "added dungeons to systems list")

if __name__ == '__main__':
    unittest.main(exit = False)

When I run this I get:

i got to here
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
>>> 

That looks like a bug in the IDE in PythonAnywhere -- the easiest workaround would be to close the console in the editor (using exit() ), then refresh the page, and start a new console using the "Bash console here" button that will appear where the old console was. Then you can use the command that @jfaccioni suggested in the comments to your question:

python3 -m unittest code.py

...but have your test results on the same browser tab as your editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM