Introduction to Testing in Python
Alexander Levin
Data Scientist
Feature
Features
Feature testing
Units:
Features:
Feature testing helps:
The scope is wider than units:
Vice versa:
Setup and defining the feature code:
# Setup
import pandas as pd
import pytest
df = pd.read_csv('laptops.csv')
# Filter feature
def filter_data_by_manuf(df, manufacturer_name):
filtered_df = df\
[df["Manufacturer"] == manufacturer_name]
return filtered_df
Testing code:
# Feature test function
def test_unique():
manuf_name = 'Apple'
filtered = filter_data_by_manuf(df, manuf_name)
assert filtered\
['Manufacturer'].nunique() == 1
assert filtered\
['Manufacturer'].unique() == [manuf_name]
Feature testing - software testing method, allows to verify the behavior of a specific feature.
Features are wider that units:
Feature testing helps to ensure that users get exactly what they expect.
To create feature tests one has to create test cases.
The key to design feature tests - to understand what the features are in a specific system.
Introduction to Testing in Python