add changelog entry for anthon's hynek-fication of options,

and change the docs and tests to use the new style.
This commit is contained in:
holger krekel 2013-08-01 17:32:19 +02:00
parent 3ac36f6572
commit 8f24e10571
19 changed files with 45 additions and 39 deletions

View File

@ -1,6 +1,12 @@
Changes between 2.3.5 and 2.4.DEV
-----------------------------------
- change to use hyphen-separated long options but keep the old spelling
backward compatible. py.test -h will only show the hyphenated version,
for example "--collect-only" but "--collectonly" will remain valid as well
(for backward-compat reasons). Many thanks to Anthon van der Neut for
the implementation and to Hynek Schlawack for pushing us.
- fix issue279: improve object comparisons on assertion failure
for standard datatypes and recognise collections.abc. Thanks to
Brianna Laugher and Mathieu Agopian.

View File

@ -72,7 +72,7 @@ consulted when reporting in ``verbose`` mode::
While developing your custom test collection and execution it's also
interesting to just look at the collection tree::
nonpython $ py.test --collectonly
nonpython $ py.test --collect-only
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
collected 2 items

View File

@ -114,7 +114,7 @@ this is a fully self-contained example which you can run with::
If you just collect tests you'll also nicely see 'advanced' and 'basic' as variants for the test function::
$ py.test --collectonly test_scenarios.py
$ py.test --collect-only test_scenarios.py
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
collected 4 items
@ -178,7 +178,7 @@ creates a database object for the actual test invocations::
Let's first see how it looks like at collection time::
$ py.test test_backends.py --collectonly
$ py.test test_backends.py --collect-only
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
collected 2 items

View File

@ -1,5 +1,5 @@
# run this with $ py.test --collectonly test_collectonly.py
# run this with $ py.test --collect-only test_collectonly.py
#
def test_function():
pass

View File

@ -41,7 +41,7 @@ in functions and classes. For example, if we have::
then the test collection looks like this::
$ py.test --collectonly
$ py.test --collect-only
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
collected 2 items
@ -80,7 +80,7 @@ Finding out what is collected
You can always peek at the collection tree without running tests like this::
. $ py.test --collectonly pythoncollection.py
. $ py.test --collect-only pythoncollection.py
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
collected 3 items
@ -133,7 +133,7 @@ and a setup.py dummy file like this::
then a pytest run on python2 will find the one test when run with a python2
interpreters and will leave out the setup.py file::
$ py.test --collectonly
$ py.test --collect-only
=========================== test session starts ============================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
collected 1 items

View File

@ -157,7 +157,7 @@ several problems:
that are never needed because it only co-ordinates the test run
activities of the slave processes.
2. if you only perform a collection (with "--collectonly")
2. if you only perform a collection (with "--collect-only")
resource-setup will still be executed.
3. If a pytest_sessionstart is contained in some subdirectories
@ -182,7 +182,7 @@ funcargs/fixture discovery now happens at collection time
pytest-2.3 takes care to discover fixture/funcarg factories
at collection time. This is more efficient especially for large test suites.
Moreover, a call to "py.test --collectonly" should be able to in the future
Moreover, a call to "py.test --collect-only" should be able to in the future
show a lot of setup-information and thus presents a nice method to get an
overview of fixture management in your project.

View File

@ -101,7 +101,7 @@ Yaml ファイルでテストを指定する基本的なサンプル
カスタムテストコレクションや実行処理の開発中、そのコレクションツリーをちょっと見るのもおもしろいです::
nonpython $ py.test --collectonly
nonpython $ py.test --collect-only
=========================== test session starts ============================
platform linux2 -- Python 2.7.1 -- pytest-2.2.4
collecting ... collected 2 items

View File

@ -218,7 +218,7 @@ Robert Collins による標準ライブラリの unittest フレームワーク
ただテストを (実行せずに) 集めるだけなら、テスト関数の変数として 'advanced' と 'basic' もうまく表示されます::
$ py.test --collectonly test_scenarios.py
$ py.test --collect-only test_scenarios.py
=========================== test session starts ============================
platform linux2 -- Python 2.7.1 -- pytest-2.2.4
collecting ... collected 2 items
@ -287,7 +287,7 @@ Robert Collins による標準ライブラリの unittest フレームワーク
コレクション時に先ほどの設定がどうなるかを最初に見てみましょう::
$ py.test test_backends.py --collectonly
$ py.test test_backends.py --collect-only
=========================== test session starts ============================
platform linux2 -- Python 2.7.1 -- pytest-2.2.4
collecting ... collected 2 items

View File

@ -1,5 +1,5 @@
# run this with $ py.test --collectonly test_collectonly.py
# run this with $ py.test --collect-only test_collectonly.py
#
def test_function():
pass

View File

@ -68,7 +68,7 @@ ini ファイルで :confval:`norecursedirs` オプションを設定できま
テストコレクションは次のようになります::
$ py.test --collectonly
$ py.test --collect-only
=========================== test session starts ============================
platform linux2 -- Python 2.7.1 -- pytest-2.2.4
collecting ... collected 2 items
@ -127,7 +127,7 @@ py.test がファイルシステムのパスから Python パッケージ名と
次のようにテストを実行せずにコレクションツリーをピークできます::
. $ py.test --collectonly pythoncollection.py
. $ py.test --collect-only pythoncollection.py
=========================== test session starts ============================
platform linux2 -- Python 2.7.1 -- pytest-2.2.4
collecting ... collected 3 items

View File

@ -273,7 +273,7 @@ funcarg ファクトリー関数は、特別なテスト関数呼び出しに関
分かりやすいように ``numiter`` の値が ``9`` のときのみテストが失敗します。 ``pytest_generate_tests(metafunc)`` フックは、実際にテストを実行するときとは違うフェーズの、テストコレクションで呼ばれることに注意してください。では、テストコレクションがどうなるかをちょっと見てみましょう::
$ py.test --collectonly test_example.py
$ py.test --collect-only test_example.py
=========================== test session starts ============================
platform linux2 -- Python 2.7.1 -- pytest-2.2.4
collecting ... collected 10 items

View File

@ -151,7 +151,7 @@ class TestGeneralUsage:
pass
""")
p = testdir.makepyfile("def test_hello(): pass")
result = testdir.runpytest(p, "--collectonly")
result = testdir.runpytest(p, "--collect-only")
result.stdout.fnmatch_lines([
"*MyFile*test_issue88*",
"*Module*test_issue88*",

View File

@ -414,7 +414,7 @@ class TestConftestCustomization:
""")
testdir.makepyfile("def test_some(): pass")
testdir.makepyfile(test_xyz="def test_func(): pass")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*<Module*test_pytest*",
"*<MyModule*xyz*",
@ -467,7 +467,7 @@ class TestConftestCustomization:
return MyFunction(name, collector)
""")
testdir.makepyfile("def some(): pass")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*MyFunction*some*",
])
@ -648,7 +648,7 @@ def test_customized_python_discovery(testdir):
""")
p2 = p.new(basename=p.basename.replace("test", "check"))
p.move(p2)
result = testdir.runpytest("--collectonly", "-s")
result = testdir.runpytest("--collect-only", "-s")
result.stdout.fnmatch_lines([
"*check_customized*",
"*check_simple*",
@ -672,7 +672,7 @@ def test_customized_python_discovery_functions(testdir):
def _test_underscore():
pass
""")
result = testdir.runpytest("--collectonly", "-s")
result = testdir.runpytest("--collect-only", "-s")
result.stdout.fnmatch_lines([
"*_test_underscore*",
])
@ -721,7 +721,7 @@ def test_customize_through_attributes(testdir):
def test_hello(self):
pass
""")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*MyClass*",
"*MyInstance*",

View File

@ -31,7 +31,7 @@ class TestFillFixtures:
def test_func(some):
pass
""")
result = testdir.runpytest() # "--collectonly")
result = testdir.runpytest() # "--collect-only")
assert result.ret != 0
result.stdout.fnmatch_lines([
"*def test_func(some)*",

View File

@ -594,7 +594,7 @@ class TestMetafuncFunctional:
def test_it(foo):
pass
""")
reprec = testdir.inline_run("--collectonly")
reprec = testdir.inline_run("--collect-only")
assert not reprec.getcalls("pytest_internalerror")
def test_usefixtures_seen_in_generate_tests(self, testdir):

View File

@ -372,7 +372,7 @@ def test_recursion_source_decode(testdir):
[pytest]
python_files = *.py
""")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines("""
<Module*>
""")

View File

@ -97,7 +97,7 @@ class TestCollectFS:
for x in tmpdir.visit("test_*.py"):
x.write("def test_hello(): pass")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
s = result.stdout.str()
assert "test_notfound" not in s
assert "test_found" in s
@ -252,7 +252,7 @@ class TestCustomConftests:
""")
sub = testdir.mkdir("sub")
p = testdir.makepyfile("def test_x(): pass")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*MyModule*",
"*test_x*"
@ -282,7 +282,7 @@ class TestCustomConftests:
p = testdir.makepyfile("def test_x(): pass")
p.copy(sub1.join(p.basename))
p.copy(sub2.join(p.basename))
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*MyModule1*",
"*MyModule2*",

View File

@ -179,7 +179,7 @@ class TestNewSession(SessionTests):
test_three="xxxdsadsadsadsa",
__init__=""
)
reprec = testdir.inline_run('--collectonly', p.dirpath())
reprec = testdir.inline_run('--collect-only', p.dirpath())
itemstarted = reprec.getcalls("pytest_itemcollected")
assert len(itemstarted) == 3
@ -238,5 +238,5 @@ def test_sessionfinish_with_start(testdir):
assert l[0] == os.getcwd()
""")
res = testdir.runpytest("--collectonly")
res = testdir.runpytest("--collect-only")
assert res.ret == 0

View File

@ -188,7 +188,7 @@ class TestCollectonly:
def test_func():
pass
""")
result = testdir.runpytest("--collectonly",)
result = testdir.runpytest("--collect-only",)
result.stdout.fnmatch_lines([
"<Module 'test_collectonly_basic.py'>",
" <Function 'test_func'>",
@ -199,7 +199,7 @@ class TestCollectonly:
import pytest
pytest.skip("hello")
""")
result = testdir.runpytest("--collectonly", "-rs")
result = testdir.runpytest("--collect-only", "-rs")
result.stdout.fnmatch_lines([
"SKIP*hello*",
"*1 skip*",
@ -207,7 +207,7 @@ class TestCollectonly:
def test_collectonly_failed_module(self, testdir):
testdir.makepyfile("""raise ValueError(0)""")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*raise ValueError*",
"*1 error*",
@ -218,7 +218,7 @@ class TestCollectonly:
def pytest_collectstart(collector):
assert 0, "urgs"
""")
result = testdir.runpytest("--collectonly")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*INTERNAL*args*"
])
@ -232,7 +232,7 @@ class TestCollectonly:
def test_method(self):
pass
""")
result = testdir.runpytest("--collectonly", p)
result = testdir.runpytest("--collect-only", p)
stderr = result.stderr.str().strip()
#assert stderr.startswith("inserting into sys.path")
assert result.ret == 0
@ -246,7 +246,7 @@ class TestCollectonly:
def test_collectonly_error(self, testdir):
p = testdir.makepyfile("import Errlkjqweqwe")
result = testdir.runpytest("--collectonly", p)
result = testdir.runpytest("--collect-only", p)
stderr = result.stderr.str().strip()
assert result.ret == 1
result.stdout.fnmatch_lines(py.code.Source("""
@ -261,7 +261,7 @@ class TestCollectonly:
failure in parseargs will cause session
not to have the items attribute
"""
result = testdir.runpytest("--collectonly", "uhm_missing_path")
result = testdir.runpytest("--collect-only", "uhm_missing_path")
assert result.ret == 4
result.stderr.fnmatch_lines([
'*ERROR: file not found*',
@ -269,14 +269,14 @@ class TestCollectonly:
def test_collectonly_quiet(self, testdir):
testdir.makepyfile("def test_foo(): pass")
result = testdir.runpytest("--collectonly", "-q")
result = testdir.runpytest("--collect-only", "-q")
result.stdout.fnmatch_lines([
'*test_foo*',
])
def test_collectonly_more_quiet(self, testdir):
testdir.makepyfile(test_fun="def test_foo(): pass")
result = testdir.runpytest("--collectonly", "-qq")
result = testdir.runpytest("--collect-only", "-qq")
result.stdout.fnmatch_lines([
'*test_fun.py: 1*',
])