Tes integrasi Python
#The overall aim of this test is to check that the two core functions of our package count_words() and plot_words() work together (at least to our test specifications).
It can be written and added to our test_pycounts.py file as follows:
from pycounts.pycounts import count_words
from pycounts.plotting import plot_words
import matplotlib
from collections import Counter
import pytest
def test_count_words():
# ... same as before ...
def test_plot_words():
# ... same as before ...
def test_plot_words_error():
# ... same as before ...
def test_integration(): <--------
"""Test count_words() and plot_words() workflow."""
counts = count_words("tests/einstein.txt")
fig = plot_words(counts)
assert isinstance(fig, matplotlib.container.BarContainer), \
"Wrong plot type"
assert len(fig.datavalues) == 10, \
"Incorrect number of bars plotted"
assert max(fig.datavalues) == 2, "Highest word count should be 2"
Imaginathan