Python-- the pycharm I use to test through unittest, there is no period for the success of the run?

at first I ran according to the code in the book, showing Ran 0 tests in 0.000s. The specific code is as follows
code to be tested:

< H1 > name_function.py < / H1 >

def get_formatted_name (first,last):
"piease enter your full name"
full_name = first +" + last
return full_name.title ()

Test code:
import unittest
from name_function import get_formatted_name

class NameTestCase (unittest.TestCase):

"""name_function.py"""
def test_first_last_name(self):
    """"""
    formatted_name = get_formatted_name("jian","ming")
    self.assertEqual(formatted_name,"Jian Ming")

unittest.main ()

running result:
Launching unittests with arguments python-m unittest E:/python code/test_name_function.py in E:python code
Ran 0 tests in 0.000s
OK
Process finished with exit code 0
Empty test suite.

then I found two solutions on the Internet
solution one:
modify
unittest.main ()
at the test code to
if name = ="_ main__":

unittest.main()

the running result is
Launching unittests with arguments python-m unittest E:/python code/test_name_function.py in E:python code
Ran 1 test in 0.001s
OK

has no period, and the result in the book is as follows:
.
Ran 1 test in 0.000s
OK

scenario 2:
Test get_formatted_name ()
steps are as follows:
after selecting the method, ctrl+shift+T, as shown in figure

Select creat New Test, to select the method. The test code is as follows:
import unittest
from name_function import get_formatted_name

class NameTestCase (unittest.TestCase):

"""name_function.py"""
def test_first_last_name(self):
    """"""
    formatted_name = get_formatted_name("jian","ming")
    self.assertEqual(formatted_name,"Jian Ming")

that is, compared with the code in the book, the unittest.main ()
running result is deleted and the result is the same as solution one. Why is there no period?

May.22,2021

caused by choosing the mode of operation

clipboard.png

1.unittestPython test
2.


clipboard.png


use your solution with pycharm,. As soon as this phenomenon occurs, there is no problem with the test code except that there is no period.

Menu