-1

I have created and activated a virtual environment, and installed pytest using pip

python3 -m venv venv
source venv/bin/activate
pip install -U pytest

The following lines are creating import errors:

import pytest

import setuptools

It's a tiny project, there are 2 files: calculator.py and test_calculator.py.

Pytest runs the unit tests when I use the pytest command, but I am not able to import pytest into the test file, and I don't have access to any of Pytest's features, e.g. @pytest.fixture, in the test file.

Ambassador Kosh
  • 459
  • 5
  • 19

1 Answers1

0

I wasn't using the python interpreter for the virtual environment. In the bottom right corner of Visual Studio Code, is the name of the Python interpreter that is being used. Click on it, and select the Python interpreter that is associated with the virtual environment.

Ambassador Kosh
  • 459
  • 5
  • 19