mercredi 4 décembre 2019

Python: I am getting Errors while running Python Unittest

I am using following python version

$ python --version
Python 3.8.0

Python folder contains only following 4

IDLE (Python 3.8 32-bit)
Python 3.8 (32-bit)
Python 3.8 Manuals (32-bit)
Python 3.8 Module Docs (32-bit)

I have following unit test in test_sum_unittest.py

import unittest


class TestSum(unittest.TestCase):

    def test_sum(self):
        self.assertEqual(sum([1, 2, 3]), 6, "Should be 6")

    def test_sum_tuple(self):
        self.assertEqual(sum((1, 2, 2)), 6, "Should be 6")

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

Ran test with

python test_sum_unittest.py

The Error logs are as below

Traceback (most recent call last):
  File "test_sum_unittest.py", line 1, in <module>
    import unittest
  File "C:\Users\ali\AppData\Local\Programs\Python\Python38-32\lib\unittest\__init__.py", line 59, in <module>
    from .result import TestResult
  File "C:\Users\ali\AppData\Local\Programs\Python\Python38-32\lib\unittest\result.py", line 5, in <module>
    import traceback
  File "C:\Users\ali\AppData\Local\Programs\Python\Python38-32\lib\traceback.py", line 5, in <module>
    import linecache
  File "C:\Users\ali\AppData\Local\Programs\Python\Python38-32\lib\linecache.py", line 11, in <module>
    import tokenize
  File "C:\Users\ali\AppData\Local\Programs\Python\Python38-32\lib\tokenize.py", line 34, in <module>
    from token import *
  File "C:\Users\ali\Flasky\Automation\token.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

What is wrong there ? any help would be appreciate, I had earlier python2.7 and I can see in tht folder I have many folder i.e. libs, scripts, Lib, Doc, Dlls, tcl, tools but thing such in python 3.8.0

Aucun commentaire:

Enregistrer un commentaire