summaryrefslogtreecommitdiff
path: root/testing/test_helpconfig.py
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2010-11-13 11:30:40 +0100
committerholger krekel <holger@merlinux.eu>2010-11-13 11:30:40 +0100
commit076e03e90f45a1424bd1ac35c2b80c3609486b23 (patch)
tree878d74c32215dc5ebf3fce2686bebb5a79f92238 /testing/test_helpconfig.py
parent929291775e38b32da89767e7016aa5736fa0ec69 (diff)
downloadpytest-076e03e90f45a1424bd1ac35c2b80c3609486b23.tar.gz
also un-nest test directory
Diffstat (limited to 'testing/test_helpconfig.py')
-rw-r--r--testing/test_helpconfig.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/test_helpconfig.py b/testing/test_helpconfig.py
new file mode 100644
index 000000000..b08c1cdc1
--- /dev/null
+++ b/testing/test_helpconfig.py
@@ -0,0 +1,53 @@
+import py, pytest,os
+from _pytest.helpconfig import collectattr
+
+def test_version(testdir):
+ result = testdir.runpytest("--version")
+ assert result.ret == 0
+ #p = py.path.local(py.__file__).dirpath()
+ result.stderr.fnmatch_lines([
+ '*py.test*%s*imported from*' % (pytest.__version__, )
+ ])
+
+def test_help(testdir):
+ result = testdir.runpytest("--help")
+ assert result.ret == 0
+ result.stdout.fnmatch_lines([
+ "*-v*verbose*",
+ "*setup.cfg*",
+ "*minversion*",
+ ])
+
+def test_collectattr():
+ class A:
+ def pytest_hello(self):
+ pass
+ class B(A):
+ def pytest_world(self):
+ pass
+ methods = py.builtin.sorted(collectattr(B))
+ assert list(methods) == ['pytest_hello', 'pytest_world']
+ methods = py.builtin.sorted(collectattr(B()))
+ assert list(methods) == ['pytest_hello', 'pytest_world']
+
+def test_hookvalidation_unknown(testdir):
+ testdir.makeconftest("""
+ def pytest_hello(xyz):
+ pass
+ """)
+ result = testdir.runpytest()
+ assert result.ret != 0
+ result.stderr.fnmatch_lines([
+ '*unknown hook*pytest_hello*'
+ ])
+
+def test_hookvalidation_optional(testdir):
+ testdir.makeconftest("""
+ import py
+ @py.test.mark.optionalhook
+ def pytest_hello(xyz):
+ pass
+ """)
+ result = testdir.runpytest()
+ assert result.ret == 0
+