1. Tetsuya Morimoto
  2. pytest

Commits

holger krekel  committed 79a5b77

draft example for skipping py2 and py3 only tests on
a per-module level.

  • Participants
  • Parent commits 1433a69
  • Branches default

Comments (0)

Files changed (4)

File doc/example/py2py3/conftest.py

View file
+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)
+
+
+

File doc/example/py2py3/test_py2.py

View file
+
+def test_exception_syntax():
+    try:
+        0/0
+    except ZeroDivisionError, e:
+        assert 0, e
+

File doc/example/py2py3/test_py2.pyc

Binary file added.

File doc/example/py2py3/test_py3.py

View file
+
+def test_exception_syntax():
+    try:
+        0/0
+    except ZeroDivisionError as e:
+        assert 0, e
+