I ran the osetests --rednose --nocapture test_report.py
I got type
for print(cls.__class__.__name__)
, but I expected TestReport
and /usr/local/bin/nosetests
for os.path.splitext(sys.modules['__main__'].__file__)[0]
, but I expected test_report
How to get it ?
class TestReport(unittest.TestCase):
@classmethod
def setup_class(cls):
print(cls.__class__.__name__)
ap(os.path.splitext(sys.modules['__main__'].__file__))
TESTING_NAME=os.path.splitext(sys.modules['__main__'].__file__)[0]
print("testing script name:"+TESTING_NAME)
Since the cls
parameter is most certainly a class
, the class of a class is of the type type
, and that's what you got when you tried to get the __name__
of it. Just try cls.__name__
and see if that gives you what you expect.
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.