Kaynağa Gözat

Add option to pytest to prevent skip

JoostSijm 3 yıl önce
ebeveyn
işleme
4299146a21
1 değiştirilmiş dosya ile 21 ekleme ve 0 silme
  1. 21 0
      tests/conftest.py

+ 21 - 0
tests/conftest.py

@@ -3,6 +3,7 @@
 import os
 
 import pytest
+import _pytest.skipping
 from dotenv import load_dotenv
 
 from rival_regions_wrapper.middleware import LocalAuthentication
@@ -15,6 +16,26 @@ class MissingAuthenticationError(Exception):
     """Error for missing authentication"""
 
 
+def pytest_addoption(parser):
+    """Add option to parser to prevent skips"""
+    parser.addoption(
+        "--no-skips",
+        action="store_true",
+        default=False, help="disable skip marks")
+
+
+@pytest.hookimpl(tryfirst=True)
+def pytest_cmdline_preparse(config, args):
+    """Add check for skips"""
+    if "--no-skips" not in args:
+        return
+
+    def no_skip(*args, **kwargs):
+        return
+
+    _pytest.skipping.skip = no_skip
+
+
 @pytest.fixture(scope='module')
 def vcr(vcr):
     """Set parameters vor VCR"""