QA Graphic

PyTest Install

Alternative way to install PyTest

PyTest Install Icon

The popular pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.

Python is a good language to learn. According to the TIOBE and PYPL index, Python is the top programing language with C and Java closely behind.

If your application is Python base, QA Engineers may find that writing automation in Python may lead to a better understanding of the code logic - which in turn will result into better testing.

If your installing PyTest on your local MacBook Pro at work, you may run into issues with permissions. The local IT department may have your computer locked down and some of the installs will require Administrator permissions.

Here are the install instructions if you have limited rights.

PyTest User Install

Use Python3 -m pip to install PyTest and Selenium:

python3 -m pip install pytest --user

python3 -m pip install selenium --user

Sample Test File

Here's a simple code sample to validate the install worked:

#!/usr/bin/env /usr/bin/python3
# Verify the Pytest was installed
import pytest
from selenium import webdriver
import sys
import requests
from import Service
from import By
from import ChromeDriverManager
from time import sleep
def test_google():
	global chrome_driver
	chrome_driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))    
	title = "Google"
	assert title == chrome_driver.title
	pageSource = chrome_driver.page_source
	gateway = "Carbon neutral since 2007"
	if not gateway in pageSource: "Google Changed their Webpage")

Save this file on your computer, I would recommend saving it in ~/pytest/

Execute Test

To execute this test, open up Terminal:

cd ~/pytest/
pytest --no-header -v



Add Comments