[Python] Python unittest fails with No module loaded in VScode

Discussão em 'Python' iniciado por Stack, Setembro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following directory structure

    [​IMG]

    when I use the test runner I get

    File "/home/kyle/dev/tests/test_foo.py", line 2, in <module> import foo ModuleNotFoundError: No module named 'foo'

    I'm at a loss as what could be wrong. The test code looks like:

    import unittest
    import foo

    class TestStringMethods(unittest.TestCase):

    def test_upper(self):
    self.assertEqual(foo.f(), 'FOO3')

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



    I'm using a virtual environment (.venv) I've set that to my interpreter.

    Continue reading...

Compartilhe esta Página