From 42d63832b7dc624bee8efeb356c03fbfd702658a Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 23 May 2012 23:40:41 +0200 Subject: [PATCH] draft example for skipping py2 and py3 only tests on a per-module level. --- doc/example/py2py3/conftest.py | 16 ++++++++++++++++ doc/example/py2py3/test_py2.py | 7 +++++++ doc/example/py2py3/test_py2.pyc | Bin 0 -> 404 bytes doc/example/py2py3/test_py3.py | 7 +++++++ 4 files changed, 30 insertions(+) create mode 100644 doc/example/py2py3/conftest.py create mode 100644 doc/example/py2py3/test_py2.py create mode 100644 doc/example/py2py3/test_py2.pyc create mode 100644 doc/example/py2py3/test_py3.py diff --git a/doc/example/py2py3/conftest.py b/doc/example/py2py3/conftest.py new file mode 100644 index 000000000..81cd1fb11 --- /dev/null +++ b/doc/example/py2py3/conftest.py @@ -0,0 +1,16 @@ +import sys +import pytest + +py3 = sys.version_info[0] >= 3 + +class DummyCollector(pytest.collect.File): + def collect(self): + return [] + +def pytest_pycollect_makemodule(path, parent): + bn = path.basename + if "py3" in bn and not py3 or ("py2" in bn and py3): + return DummyCollector(path, parent=parent) + + + diff --git a/doc/example/py2py3/test_py2.py b/doc/example/py2py3/test_py2.py new file mode 100644 index 000000000..a035ec723 --- /dev/null +++ b/doc/example/py2py3/test_py2.py @@ -0,0 +1,7 @@ + +def test_exception_syntax(): + try: + 0/0 + except ZeroDivisionError, e: + assert 0, e + diff --git a/doc/example/py2py3/test_py2.pyc b/doc/example/py2py3/test_py2.pyc new file mode 100644 index 0000000000000000000000000000000000000000..495a2f6420416f26bd1e5012f55c3977a114a9bf GIT binary patch literal 404 zcmbtP!Ab)$6r9&8$kK`)dhr8fPYvox5UHrw3VNvYQp#?itKCgVqU?fR#6R-vPx%E- zqQws|YnY8EpEm`5hj5*+{E$!r@4%dm;4bfxNxG=nW?i!UDWMxg1?Na+ z%^|h|@Q}eAK;#t=9@q>L1TVl_57MyiY5wCmt!RN{ANJYJwKG@MbLA`3Tsvo6*d=@6 zy>?+klioNZV`AhvrbTU7yP5HFe=P50QeFHoNRPO)) literal 0 HcmV?d00001 diff --git a/doc/example/py2py3/test_py3.py b/doc/example/py2py3/test_py3.py new file mode 100644 index 000000000..615b50fbb --- /dev/null +++ b/doc/example/py2py3/test_py3.py @@ -0,0 +1,7 @@ + +def test_exception_syntax(): + try: + 0/0 + except ZeroDivisionError as e: + assert 0, e +