Skip to content

Commit

Permalink
Simplify wycheproof pytest code (#5579)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Nov 20, 2020
1 parent fd582e8 commit 2b85c4d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
4 changes: 1 addition & 3 deletions tests/conftest.py
Expand Up @@ -11,7 +11,6 @@
from .utils import (
check_backend_support,
load_wycheproof_tests,
skip_if_wycheproof_none,
)


Expand All @@ -30,8 +29,7 @@ def pytest_addoption(parser):

def pytest_generate_tests(metafunc):
if "wycheproof" in metafunc.fixturenames:
wycheproof = metafunc.config.getoption("--wycheproof-root")
skip_if_wycheproof_none(wycheproof)
wycheproof = metafunc.config.getoption("--wycheproof-root", skip=True)

testcases = []
marker = metafunc.definition.get_closest_marker("wycheproof_tests")
Expand Down
7 changes: 0 additions & 7 deletions tests/utils.py
Expand Up @@ -906,13 +906,6 @@ def has_flag(self, flag):
return flag in self.testcase["flags"]


def skip_if_wycheproof_none(wycheproof):
# This is factored into its own function so we can easily test both
# branches
if wycheproof is None:
pytest.skip("--wycheproof-root not provided")


def load_wycheproof_tests(wycheproof, test_file):
path = os.path.join(wycheproof, "testvectors", test_file)
with open(path) as f:
Expand Down
11 changes: 1 addition & 10 deletions tests/wycheproof/test_utils.py
Expand Up @@ -4,18 +4,9 @@

from __future__ import absolute_import, division, print_function

import pytest

from ..utils import WycheproofTest, skip_if_wycheproof_none
from ..utils import WycheproofTest


def test_wycheproof_test_repr():
wycheproof = WycheproofTest({}, {}, {"tcId": 3})
assert repr(wycheproof) == "<WycheproofTest({}, {}, {'tcId': 3}, tcId=3)>"


def test_skip_if_wycheproof_none():
with pytest.raises(pytest.skip.Exception):
skip_if_wycheproof_none(None)

skip_if_wycheproof_none("abc")

0 comments on commit 2b85c4d

Please sign in to comment.