Sunday morning, I decided to start this blog post.
So I started watching the course and followed each step.
Python Virtual Environments
I’m doing this course in my Ubuntu machine. I started the tutorial in Windows 10 but… everything is more complicated in Windows for some reason.
I failed creatinv the virtual environment with Python 2.7, but I could do it with Python 3.
First, I installed the python-3-venv dependency. Then I created the virtual environment and activated the source. So, now everything I do is only in the venv.
To test it, I installed pytest, I ran the command and it was identified. Then, I deactivated the virtual environment by executing deactivate, I ran pytest againg and the command was not found.
Setup pytest in PyCharm
I installed PyCharm Community with the command
I followed the wizard:
- Created the project pytest_test
- Clicked Next
The IDE created a new Virtual Environment and I decided to continue with it. Next, I created the first failing test.
Then, I added pytest to the project by going to Run > Edit Configurations. I clicked on Add New Configuration and I chose the pytest option. I changed the name to Unit Tests and picked the pytest_test.py file in the Target field.
Next, I installed pytest in Pycharm using the Terminal.
Then, I could run the test by clicking the green play button at the right top of the window. As expected, the test failed.
I changed the test and now it passes!