<s>
Pytest	B-Language
is	O
a	O
Python	B-Language
testing	O
framework	B-Architecture
that	O
originated	O
from	O
the	O
PyPy	B-Language
project	O
.	O
</s>
<s>
It	O
can	O
be	O
used	O
to	O
write	O
various	O
types	O
of	O
software	O
tests	O
,	O
including	O
unit	O
tests	O
,	O
integration	O
tests	O
,	O
end-to-end	O
tests	O
,	O
and	O
functional	B-Application
tests	I-Application
.	O
</s>
<s>
Pytest	B-Language
fixtures	O
provide	O
the	O
contexts	O
for	O
tests	O
by	O
passing	O
in	O
parameter	O
names	O
in	O
test	O
cases	O
;	O
its	O
parametrization	O
eliminates	O
duplicate	O
code	O
for	O
testing	O
multiple	O
sets	O
of	O
input	O
and	O
output	O
;	O
and	O
its	O
rewritten	O
assert	O
statements	O
provide	O
detailed	O
output	O
for	O
causes	O
of	O
failures	O
.	O
</s>
<s>
Pytest	B-Language
was	O
developed	O
as	O
part	O
of	O
an	O
effort	O
by	O
third-party	B-Language
packages	I-Language
to	O
address	O
Python	B-Language
's	O
built-in	O
module	B-Architecture
unittest	O
's	O
shortcomings	O
.	O
</s>
<s>
It	O
originated	O
as	O
part	O
of	O
PyPy	B-Language
,	O
an	O
alternative	O
implementation	O
of	O
Python	B-Language
to	O
the	O
standard	O
CPython	B-Language
.	O
</s>
<s>
Since	O
its	O
creation	O
in	O
early	O
2003	O
,	O
PyPy	B-Language
has	O
had	O
a	O
heavy	O
emphasis	O
on	O
testing	O
.	O
</s>
<s>
PyPy	B-Language
had	O
unit	O
tests	O
for	O
newly	O
written	O
code	O
,	O
regression	O
tests	O
for	O
bugs	O
,	O
and	O
integration	O
tests	O
using	O
CPython	B-Language
's	O
test	O
suite	O
.	O
</s>
<s>
In	O
mid	O
2004	O
,	O
a	O
testing	O
framework	B-Architecture
called	O
utest	O
emerged	O
and	O
contributors	O
to	O
PyPy	B-Language
began	O
converting	O
existing	O
test	O
cases	O
to	O
utest	O
.	O
</s>
<s>
Meanwhile	O
,	O
at	O
EuroPython	O
2004	O
a	O
complementary	O
standard	B-Library
library	I-Library
for	O
testing	O
,	O
named	O
std	O
,	O
was	O
invented	O
.	O
</s>
<s>
This	O
package	O
laid	O
out	O
the	O
principles	O
,	O
such	O
as	O
assert	O
rewriting	O
,	O
of	O
what	O
would	O
later	O
become	O
pytest	B-Language
.	O
</s>
<s>
In	O
late	O
2004	O
,	O
the	O
std	O
project	O
was	O
renamed	O
to	O
py	O
,	O
std.utest	O
became	O
py.test	O
,	O
and	O
the	O
py	O
library	B-Library
was	O
separated	O
from	O
PyPy	B-Language
.	O
</s>
<s>
In	O
November	O
2010	O
,	O
pytest	B-Language
2.0.0	O
was	O
released	O
as	O
a	O
package	O
separate	O
from	O
py	O
.	O
</s>
<s>
It	O
was	O
still	O
called	O
py.test	O
until	O
August	O
2016	O
,	O
but	O
following	O
the	O
release	O
of	O
pytest	B-Language
3.0.0	O
the	O
recommended	O
command	B-Application
line	I-Application
entry	B-Language
point	I-Language
became	O
pytest	B-Language
.	O
</s>
<s>
Pytest	B-Language
has	O
been	O
classified	O
by	O
developer	O
security	O
platform	O
Snyk	O
as	O
one	O
of	O
the	O
key	O
ecosystem	O
projects	O
in	O
Python	B-Language
due	O
to	O
its	O
popularity	O
.	O
</s>
<s>
Some	O
well-known	O
projects	O
who	O
switched	O
to	O
pytest	B-Language
from	O
unittest	O
and	O
nose	O
(	O
another	O
testing	O
package	O
)	O
include	O
those	O
of	O
Mozilla	B-Operating_System
and	O
Dropbox	B-Application
.	O
</s>
<s>
In	O
many	O
cases	O
,	O
in	O
order	O
to	O
thoroughly	O
test	B-Application
functionalities	I-Application
,	O
one	O
needs	O
to	O
test	O
multiple	O
sets	O
of	O
input/output	O
,	O
and	O
writing	O
such	O
cases	O
separately	O
would	O
cause	O
duplicate	O
code	O
as	O
most	O
of	O
the	O
actions	O
would	O
remain	O
the	O
same	O
,	O
only	O
differing	O
in	O
input/output	O
values	O
.	O
</s>
<s>
Pytest	B-Language
's	O
parametrized	O
testing	O
feature	O
eliminates	O
such	O
duplicate	O
code	O
by	O
combining	O
different	O
iterations	O
into	O
one	O
test	O
case	O
,	O
then	O
running	O
these	O
iterations	O
and	O
displaying	O
each	O
test	O
's	O
result	O
separately	O
.	O
</s>
<s>
Parametrized	O
tests	O
in	O
pytest	B-Language
are	O
marked	O
by	O
the	O
decorator	O
,	O
where	O
the	O
first	O
parameter	O
,	O
,	O
is	O
a	O
string	O
of	O
comma-separated	O
names	O
,	O
and	O
is	O
a	O
list	O
of	O
values	O
to	O
pass	O
into	O
.	O
</s>
<s>
The	O
names	O
in	O
are	O
then	O
passed	O
into	O
the	O
test	O
function	B-Language
marked	O
by	O
the	O
decorator	O
as	O
parameters	O
.	O
</s>
<s>
When	O
pytest	B-Language
runs	O
such	O
decorated	O
tests	O
,	O
each	O
pair	O
of	O
and	O
would	O
constitute	O
a	O
separate	O
run	O
with	O
its	O
own	O
test	O
output	O
and	O
unique	O
identifier	O
.	O
</s>
<s>
While	O
Python	B-Language
's	O
built-in	O
assert	O
keyword	O
would	O
only	O
raise	O
AssertionError	O
with	O
no	O
details	O
in	O
cases	O
of	O
failure	O
,	O
pytest	B-Language
rewrites	O
Python	B-Language
's	O
assert	O
keyword	O
and	O
provides	O
detailed	O
output	O
for	O
the	O
causes	O
of	O
failures	O
,	O
such	O
as	O
what	O
expressions	O
in	O
the	O
assert	O
statement	O
evaluate	O
to	O
.	O
</s>
<s>
A	O
comparison	O
can	O
be	O
made	O
with	O
unittest	O
(	O
Python	B-Language
's	O
built-in	O
module	B-Architecture
for	O
testing	O
)	O
'	O
s	O
assert	O
statements	O
:	O
</s>
<s>
adheres	O
to	O
a	O
more	O
verbose	O
syntax	O
because	O
it	O
is	O
inspired	O
by	O
the	O
Java	B-Language
programming	I-Language
language	I-Language
's	O
JUnit	B-Language
,	O
as	O
are	O
most	O
unit	O
testing	O
libraries	O
;	O
pytest	B-Language
achieves	O
the	O
same	O
while	O
intercepting	O
Python	B-Language
's	O
built-in	O
assert	O
calls	O
,	O
making	O
the	O
approach	O
more	O
concise	O
.	O
</s>
<s>
Pytest	B-Language
's	O
tests	O
verify	O
that	O
computer	O
code	O
performs	O
as	O
expected	O
using	O
tests	O
that	O
are	O
structured	O
in	O
an	O
arrange	O
,	O
act	O
and	O
assert	O
sequence	O
known	O
as	O
AAA	O
.	O
</s>
<s>
They	O
can	O
be	O
used	O
to	O
put	O
a	O
system	O
into	O
a	O
known	O
state	B-Application
and	O
to	O
pass	O
data	O
into	O
test	O
functions	O
.	O
</s>
<s>
Pytest	B-Language
fixtures	O
can	O
run	O
before	O
test	O
cases	O
as	O
setup	O
or	O
after	O
test	O
cases	O
for	O
clean	O
up	O
,	O
but	O
are	O
different	O
from	O
unittest	O
and	O
nose	O
(	O
another	O
third-party	O
Python	B-Language
testing	O
framework	B-Architecture
)	O
'	O
s	O
setups	O
and	O
teardowns	O
.	O
</s>
<s>
Functions	O
declared	O
as	O
pytest	B-Language
fixtures	O
are	O
marked	O
by	O
the	O
decorator	O
,	O
whose	O
names	O
can	O
then	O
be	O
passed	O
into	O
test	O
functions	O
as	O
parameters	O
.	O
</s>
<s>
When	O
pytest	B-Language
finds	O
the	O
fixtures	O
 '	O
names	O
in	O
test	O
functions	O
 '	O
parameters	O
,	O
it	O
first	O
searches	O
in	O
the	O
same	O
module	B-Architecture
for	O
such	O
fixtures	O
,	O
and	O
if	O
not	O
found	O
,	O
it	O
searches	O
for	O
such	O
fixtures	O
in	O
the	O
conftest.py	O
file	O
.	O
</s>
<s>
In	O
the	O
above	O
example	O
,	O
pytest	B-Language
fixture	O
returns	O
a	O
dictionary	O
,	O
which	O
is	O
then	O
passed	O
into	O
test	O
function	B-Language
for	O
assertion	O
.	O
</s>
<s>
In	O
addition	O
to	O
fixture	O
detection	O
within	O
the	O
same	O
file	O
as	O
test	O
cases	O
,	O
pytest	B-Language
fixtures	O
can	O
also	O
be	O
placed	O
in	O
the	O
conftest.py	O
file	O
in	O
the	O
tests	O
directory	O
.	O
</s>
<s>
In	O
pytest	B-Language
,	O
fixture	O
scopes	O
let	O
the	O
user	O
define	O
when	O
a	O
fixture	O
should	O
be	O
called	O
.	O
</s>
<s>
There	O
are	O
four	O
fixture	O
scopes	O
:	O
function	B-Language
scope	O
,	O
class	O
scope	O
,	O
module	B-Architecture
scope	O
,	O
and	O
session	O
scope	O
.	O
</s>
<s>
Function-scoped	O
fixtures	O
are	O
default	O
for	O
all	O
pytest	B-Language
fixtures	O
,	O
which	O
are	O
called	O
every	O
time	O
a	O
function	B-Language
having	O
the	O
fixture	O
as	O
a	O
parameter	O
runs	O
.	O
</s>
<s>
Another	O
feature	O
of	O
pytest	B-Language
is	O
its	O
ability	O
to	O
filter	O
through	O
tests	O
,	O
where	O
only	O
desired	O
tests	O
are	O
selected	O
to	O
run	O
,	O
or	O
behave	O
in	O
a	O
certain	O
way	O
as	O
desired	O
by	O
the	O
developer	O
.	O
</s>
<s>
)	O
,	O
pytest	B-Language
would	O
only	O
run	O
tests	O
whose	O
names	O
include	O
.	O
</s>
<s>
The	O
opposite	O
is	O
true	O
,	O
where	O
one	O
can	O
run	O
,	O
and	O
pytest	B-Language
will	O
run	O
all	O
tests	O
whose	O
names	O
do	O
not	O
include	O
.	O
</s>
<s>
Pytest	B-Language
's	O
markers	O
can	O
,	O
in	O
addition	O
to	O
altering	O
test	O
behaviour	O
,	O
also	O
filter	O
tests	O
.	O
</s>
<s>
Pytest	B-Language
's	O
markers	O
are	O
Python	B-Language
decorators	O
starting	O
with	O
the	O
syntax	O
placed	O
on	O
top	O
of	O
test	O
functions	O
.	O
</s>
<s>
With	O
different	O
arbitrarily	O
named	O
markers	O
,	O
running	O
on	O
the	O
command	B-Application
line	I-Application
will	O
only	O
run	O
those	O
tests	O
decorated	O
with	O
such	O
markers	O
.	O
</s>
<s>
All	O
available	O
markers	O
can	O
be	O
listed	O
by	O
the	O
along	O
with	O
their	O
descriptions	O
;	O
custom	O
markers	O
can	O
also	O
be	O
defined	O
by	O
users	O
and	O
registered	O
in	O
pytest.ini	O
,	O
in	O
which	O
case	O
will	O
also	O
list	O
those	O
custom	O
markers	O
along	O
with	O
builtin	O
markers	O
.	O
</s>
