actually regen fixture docs with python3.4 instead of python2.7 (doh)
This commit is contained in:
parent
e98f77037e
commit
9232b88df3
|
@ -75,26 +75,25 @@ will discover and call the :py:func:`@pytest.fixture <_pytest.python.fixture>`
|
||||||
marked ``smtp`` fixture function. Running the test looks like this::
|
marked ``smtp`` fixture function. Running the test looks like this::
|
||||||
|
|
||||||
$ py.test test_smtpsimple.py
|
$ py.test test_smtpsimple.py
|
||||||
============================= test session starts ==============================
|
=========================== test session starts ============================
|
||||||
platform linux2 -- Python 2.7.6 -- py-1.4.23 -- pytest-2.6.1
|
platform linux -- Python 3.4.0 -- py-1.4.23 -- pytest-2.6.2.dev1
|
||||||
collected 1 items
|
collected 1 items
|
||||||
|
|
||||||
test_smtpsimple.py F
|
test_smtpsimple.py F
|
||||||
|
|
||||||
=================================== FAILURES ===================================
|
================================= FAILURES =================================
|
||||||
__________________________________ test_ehlo ___________________________________
|
________________________________ test_ehlo _________________________________
|
||||||
|
|
||||||
smtp = <smtplib.SMTP instance at 0x7ff89e00d7e8>
|
smtp = <smtplib.SMTP object at 0x2ade77b37e48>
|
||||||
|
|
||||||
def test_ehlo(smtp):
|
def test_ehlo(smtp):
|
||||||
response, msg = smtp.ehlo()
|
response, msg = smtp.ehlo()
|
||||||
assert response == 250
|
assert response == 250
|
||||||
assert "merlinux" in msg
|
> assert "merlinux" in msg
|
||||||
> assert 0 # for demo purposes
|
E TypeError: Type str doesn't support the buffer API
|
||||||
E assert 0
|
|
||||||
|
|
||||||
test_smtpsimple.py:12: AssertionError
|
test_smtpsimple.py:11: TypeError
|
||||||
=========================== 1 failed in 0.17 seconds ===========================
|
========================= 1 failed in 0.18 seconds =========================
|
||||||
|
|
||||||
In the failure traceback we see that the test function was called with a
|
In the failure traceback we see that the test function was called with a
|
||||||
``smtp`` argument, the ``smtplib.SMTP()`` instance created by the fixture
|
``smtp`` argument, the ``smtplib.SMTP()`` instance created by the fixture
|
||||||
|
@ -193,28 +192,27 @@ We deliberately insert failing ``assert 0`` statements in order to
|
||||||
inspect what is going on and can now run the tests::
|
inspect what is going on and can now run the tests::
|
||||||
|
|
||||||
$ py.test test_module.py
|
$ py.test test_module.py
|
||||||
============================= test session starts ==============================
|
=========================== test session starts ============================
|
||||||
platform linux2 -- Python 2.7.6 -- py-1.4.23 -- pytest-2.6.1
|
platform linux -- Python 3.4.0 -- py-1.4.23 -- pytest-2.6.2.dev1
|
||||||
collected 2 items
|
collected 2 items
|
||||||
|
|
||||||
test_module.py FF
|
test_module.py FF
|
||||||
|
|
||||||
=================================== FAILURES ===================================
|
================================= FAILURES =================================
|
||||||
__________________________________ test_ehlo ___________________________________
|
________________________________ test_ehlo _________________________________
|
||||||
|
|
||||||
smtp = <smtplib.SMTP instance at 0x7f36c67e3ab8>
|
smtp = <smtplib.SMTP object at 0x2b4b07e38e48>
|
||||||
|
|
||||||
def test_ehlo(smtp):
|
def test_ehlo(smtp):
|
||||||
response = smtp.ehlo()
|
response = smtp.ehlo()
|
||||||
assert response[0] == 250
|
assert response[0] == 250
|
||||||
assert "merlinux" in response[1]
|
> assert "merlinux" in response[1]
|
||||||
> assert 0 # for demo purposes
|
E TypeError: Type str doesn't support the buffer API
|
||||||
E assert 0
|
|
||||||
|
|
||||||
test_module.py:6: AssertionError
|
test_module.py:5: TypeError
|
||||||
__________________________________ test_noop ___________________________________
|
________________________________ test_noop _________________________________
|
||||||
|
|
||||||
smtp = <smtplib.SMTP instance at 0x7f36c67e3ab8>
|
smtp = <smtplib.SMTP object at 0x2b4b07e38e48>
|
||||||
|
|
||||||
def test_noop(smtp):
|
def test_noop(smtp):
|
||||||
response = smtp.noop()
|
response = smtp.noop()
|
||||||
|
@ -223,7 +221,7 @@ inspect what is going on and can now run the tests::
|
||||||
E assert 0
|
E assert 0
|
||||||
|
|
||||||
test_module.py:11: AssertionError
|
test_module.py:11: AssertionError
|
||||||
=========================== 2 failed in 0.17 seconds ===========================
|
========================= 2 failed in 0.18 seconds =========================
|
||||||
|
|
||||||
You see the two ``assert 0`` failing and more importantly you can also see
|
You see the two ``assert 0`` failing and more importantly you can also see
|
||||||
that the same (module-scoped) ``smtp`` object was passed into the two
|
that the same (module-scoped) ``smtp`` object was passed into the two
|
||||||
|
@ -311,8 +309,7 @@ We use the ``request.module`` attribute to optionally obtain an
|
||||||
again, nothing much has changed::
|
again, nothing much has changed::
|
||||||
|
|
||||||
$ py.test -s -q --tb=no
|
$ py.test -s -q --tb=no
|
||||||
FFteardown smtp
|
FF
|
||||||
|
|
||||||
2 failed in 0.17 seconds
|
2 failed in 0.17 seconds
|
||||||
|
|
||||||
Let's quickly create another test module that actually sets the
|
Let's quickly create another test module that actually sets the
|
||||||
|
@ -329,11 +326,11 @@ Running it::
|
||||||
|
|
||||||
$ py.test -qq --tb=short test_anothersmtp.py
|
$ py.test -qq --tb=short test_anothersmtp.py
|
||||||
F
|
F
|
||||||
=================================== FAILURES ===================================
|
================================= FAILURES =================================
|
||||||
________________________________ test_showhelo _________________________________
|
______________________________ test_showhelo _______________________________
|
||||||
test_anothersmtp.py:5: in test_showhelo
|
test_anothersmtp.py:5: in test_showhelo
|
||||||
assert 0, smtp.helo()
|
assert 0, smtp.helo()
|
||||||
E AssertionError: (250, 'hq.merlinux.eu')
|
E AssertionError: (250, b'mail.python.org')
|
||||||
|
|
||||||
voila! The ``smtp`` fixture function picked up our mail server name
|
voila! The ``smtp`` fixture function picked up our mail server name
|
||||||
from the module namespace.
|
from the module namespace.
|
||||||
|
@ -377,46 +374,21 @@ So let's just do another run::
|
||||||
|
|
||||||
$ py.test -q test_module.py
|
$ py.test -q test_module.py
|
||||||
FFFF
|
FFFF
|
||||||
=================================== FAILURES ===================================
|
================================= FAILURES =================================
|
||||||
____________________________ test_ehlo[merlinux.eu] ____________________________
|
__________________________ test_ehlo[merlinux.eu] __________________________
|
||||||
|
|
||||||
smtp = <smtplib.SMTP instance at 0x7f4fdf04cea8>
|
smtp = <smtplib.SMTP object at 0x2b824acf3e80>
|
||||||
|
|
||||||
def test_ehlo(smtp):
|
|
||||||
response = smtp.ehlo()
|
|
||||||
assert response[0] == 250
|
|
||||||
assert "merlinux" in response[1]
|
|
||||||
> assert 0 # for demo purposes
|
|
||||||
E assert 0
|
|
||||||
|
|
||||||
test_module.py:6: AssertionError
|
|
||||||
____________________________ test_noop[merlinux.eu] ____________________________
|
|
||||||
|
|
||||||
smtp = <smtplib.SMTP instance at 0x7f4fdf04cea8>
|
|
||||||
|
|
||||||
def test_noop(smtp):
|
|
||||||
response = smtp.noop()
|
|
||||||
assert response[0] == 250
|
|
||||||
> assert 0 # for demo purposes
|
|
||||||
E assert 0
|
|
||||||
|
|
||||||
test_module.py:11: AssertionError
|
|
||||||
__________________________ test_ehlo[mail.python.org] __________________________
|
|
||||||
|
|
||||||
smtp = <smtplib.SMTP instance at 0x7f4fdf07c290>
|
|
||||||
|
|
||||||
def test_ehlo(smtp):
|
def test_ehlo(smtp):
|
||||||
response = smtp.ehlo()
|
response = smtp.ehlo()
|
||||||
assert response[0] == 250
|
assert response[0] == 250
|
||||||
> assert "merlinux" in response[1]
|
> assert "merlinux" in response[1]
|
||||||
E assert 'merlinux' in 'mail.python.org\nSIZE 25600000\nETRN\nSTARTTLS\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8'
|
E TypeError: Type str doesn't support the buffer API
|
||||||
|
|
||||||
test_module.py:5: AssertionError
|
test_module.py:5: TypeError
|
||||||
---------------------------- Captured stdout setup -----------------------------
|
__________________________ test_noop[merlinux.eu] __________________________
|
||||||
finalizing <smtplib.SMTP instance at 0x7f4fdf04cea8>
|
|
||||||
__________________________ test_noop[mail.python.org] __________________________
|
|
||||||
|
|
||||||
smtp = <smtplib.SMTP instance at 0x7f4fdf07c290>
|
smtp = <smtplib.SMTP object at 0x2b824acf3e80>
|
||||||
|
|
||||||
def test_noop(smtp):
|
def test_noop(smtp):
|
||||||
response = smtp.noop()
|
response = smtp.noop()
|
||||||
|
@ -425,7 +397,31 @@ So let's just do another run::
|
||||||
E assert 0
|
E assert 0
|
||||||
|
|
||||||
test_module.py:11: AssertionError
|
test_module.py:11: AssertionError
|
||||||
4 failed in 6.26 seconds
|
________________________ test_ehlo[mail.python.org] ________________________
|
||||||
|
|
||||||
|
smtp = <smtplib.SMTP object at 0x2b824b19fb38>
|
||||||
|
|
||||||
|
def test_ehlo(smtp):
|
||||||
|
response = smtp.ehlo()
|
||||||
|
assert response[0] == 250
|
||||||
|
> assert "merlinux" in response[1]
|
||||||
|
E TypeError: Type str doesn't support the buffer API
|
||||||
|
|
||||||
|
test_module.py:5: TypeError
|
||||||
|
-------------------------- Captured stdout setup ---------------------------
|
||||||
|
finalizing <smtplib.SMTP object at 0x2b824acf3e80>
|
||||||
|
________________________ test_noop[mail.python.org] ________________________
|
||||||
|
|
||||||
|
smtp = <smtplib.SMTP object at 0x2b824b19fb38>
|
||||||
|
|
||||||
|
def test_noop(smtp):
|
||||||
|
response = smtp.noop()
|
||||||
|
assert response[0] == 250
|
||||||
|
> assert 0 # for demo purposes
|
||||||
|
E assert 0
|
||||||
|
|
||||||
|
test_module.py:11: AssertionError
|
||||||
|
4 failed in 6.37 seconds
|
||||||
|
|
||||||
We see that our two test functions each ran twice, against the different
|
We see that our two test functions each ran twice, against the different
|
||||||
``smtp`` instances. Note also, that with the ``mail.python.org``
|
``smtp`` instances. Note also, that with the ``mail.python.org``
|
||||||
|
@ -464,14 +460,14 @@ Here we declare an ``app`` fixture which receives the previously defined
|
||||||
``smtp`` fixture and instantiates an ``App`` object with it. Let's run it::
|
``smtp`` fixture and instantiates an ``App`` object with it. Let's run it::
|
||||||
|
|
||||||
$ py.test -v test_appsetup.py
|
$ py.test -v test_appsetup.py
|
||||||
============================= test session starts ==============================
|
=========================== test session starts ============================
|
||||||
platform linux2 -- Python 2.7.6 -- py-1.4.23 -- pytest-2.6.1 -- /home/hpk/venv/0/bin/python
|
platform linux -- Python 3.4.0 -- py-1.4.23 -- pytest-2.6.2.dev1 -- /home/hpk/p/pytest/.tox/regen/bin/python3.4
|
||||||
collecting ... collected 2 items
|
collecting ... collected 2 items
|
||||||
|
|
||||||
test_appsetup.py::test_smtp_exists[merlinux.eu] PASSED
|
test_appsetup.py::test_smtp_exists[merlinux.eu] PASSED
|
||||||
test_appsetup.py::test_smtp_exists[mail.python.org] PASSED
|
test_appsetup.py::test_smtp_exists[mail.python.org] PASSED
|
||||||
|
|
||||||
=========================== 2 passed in 5.46 seconds ===========================
|
========================= 2 passed in 6.11 seconds =========================
|
||||||
|
|
||||||
Due to the parametrization of ``smtp`` the test will run twice with two
|
Due to the parametrization of ``smtp`` the test will run twice with two
|
||||||
different ``App`` instances and respective smtp servers. There is no
|
different ``App`` instances and respective smtp servers. There is no
|
||||||
|
@ -528,30 +524,30 @@ to show the setup/teardown flow::
|
||||||
Let's run the tests in verbose mode and with looking at the print-output::
|
Let's run the tests in verbose mode and with looking at the print-output::
|
||||||
|
|
||||||
$ py.test -v -s test_module.py
|
$ py.test -v -s test_module.py
|
||||||
============================= test session starts ==============================
|
=========================== test session starts ============================
|
||||||
platform linux2 -- Python 2.7.6 -- py-1.4.23 -- pytest-2.6.1 -- /home/hpk/venv/0/bin/python
|
platform linux -- Python 3.4.0 -- py-1.4.23 -- pytest-2.6.2.dev1 -- /home/hpk/p/pytest/.tox/regen/bin/python3.4
|
||||||
collecting ... collected 8 items
|
collecting ... collected 8 items
|
||||||
|
|
||||||
test_module.py::test_0[1] (' test0', 1)
|
test_module.py::test_0[1] test0 1
|
||||||
PASSED
|
PASSED
|
||||||
test_module.py::test_0[2] (' test0', 2)
|
test_module.py::test_0[2] test0 2
|
||||||
PASSED
|
PASSED
|
||||||
test_module.py::test_1[mod1] ('create', 'mod1')
|
test_module.py::test_1[mod1] create mod1
|
||||||
(' test1', 'mod1')
|
test1 mod1
|
||||||
PASSED
|
PASSED
|
||||||
test_module.py::test_2[1-mod1] (' test2', 1, 'mod1')
|
test_module.py::test_2[1-mod1] test2 1 mod1
|
||||||
PASSED
|
PASSED
|
||||||
test_module.py::test_2[2-mod1] (' test2', 2, 'mod1')
|
test_module.py::test_2[2-mod1] test2 2 mod1
|
||||||
PASSED
|
PASSED
|
||||||
test_module.py::test_1[mod2] ('create', 'mod2')
|
test_module.py::test_1[mod2] create mod2
|
||||||
(' test1', 'mod2')
|
test1 mod2
|
||||||
PASSED
|
PASSED
|
||||||
test_module.py::test_2[1-mod2] (' test2', 1, 'mod2')
|
test_module.py::test_2[1-mod2] test2 1 mod2
|
||||||
PASSED
|
PASSED
|
||||||
test_module.py::test_2[2-mod2] (' test2', 2, 'mod2')
|
test_module.py::test_2[2-mod2] test2 2 mod2
|
||||||
PASSED
|
PASSED
|
||||||
|
|
||||||
=========================== 8 passed in 0.01 seconds ===========================
|
========================= 8 passed in 0.01 seconds =========================
|
||||||
|
|
||||||
You can see that the parametrized module-scoped ``modarg`` resource caused
|
You can see that the parametrized module-scoped ``modarg`` resource caused
|
||||||
an ordering of test execution that lead to the fewest possible "active" resources. The finalizer for the ``mod1`` parametrized resource was executed
|
an ordering of test execution that lead to the fewest possible "active" resources. The finalizer for the ``mod1`` parametrized resource was executed
|
||||||
|
|
Loading…
Reference in New Issue