python - HTML Test runner giving error to import stringIO even after importing it -
hi i'm using following code implement html test runner in code:
import htmltestrunner import unittest io import stringio class teststringmethods(unittest.testcase): """ example test htmlrunner. """ def test_upper(self): self.assertequal('foo'.upper(), 'foo') def test_isupper(self): self.asserttrue('foo'.isupper()) self.assertfalse('foo'.isupper()) def test_split(self): s = 'hello world' self.assertequal(s.split(), ['hello', 'world']) # check s.split fails when separator not string self.assertraises(typeerror): s.split(2) def test_error(self): """ test should marked error one. """ raise valueerror def test_fail(self): """ test should fail. """ self.assertequal(1, 2) @unittest.skip("this skipped test.") def test_skip(self): """ test should skipped. """ pass if __name__ == '__main__': unittest.main(testrunner=htmltestrunner.htmltestrunner(output='test_dir')) but getting following error:
c:\users\inswadhwa\appdata\local\programs\python\python36-32\python.exe c:/users/inswadhwa/pycharmprojects/automation/assertion.py traceback (most recent call last): file "c:/users/inswadhwa/pycharmprojects/automation/assertion.py", line 2, in import htmltestrunner file "c:\users\inswadhwa\appdata\local\programs\python\python36-32\lib\htmltestrunner.py", line 97, in import stringio modulenotfounderror: no module named 'stringio' process finished exit code 1
i have imported stringio.
can please suggest way overcome issue?
it looks you're using this library, appears not have been updated work python 3, the old stringio module has been replaced io.stringio class.
try using html-testrunner instead. should work python 3.
Comments
Post a Comment