Loading pkgs/development/python-modules/hypothesmith/default.nix +10 −23 Original line number Diff line number Diff line { lib, black, buildPythonPackage, fetchPypi, hypothesis, Loading @@ -7,59 +8,45 @@ libcst, parso, pytestCheckHook, pytest-cov-stub, pytest-xdist, pythonOlder, setuptools, }: buildPythonPackage rec { pname = "hypothesmith"; version = "0.3.3"; format = "setuptools"; pyproject = true; disabled = pythonOlder "3.8"; disabled = pythonOlder "3.9"; src = fetchPypi { inherit pname version; hash = "sha256-lsFIAtbI6F2JdSZBdoeNtUso0u2SH9v+3C5rjOPIFxY="; }; patches = [ ./remove-black.patch ]; build-system = [ setuptools ]; postPatch = '' substituteInPlace setup.py \ --replace "lark-parser" "lark" substituteInPlace tox.ini \ --replace "--cov=hypothesmith" "" \ --replace "--cov-branch" "" \ --replace "--cov-report=term-missing:skip-covered" "" \ --replace "--cov-fail-under=100" "" ''; propagatedBuildInputs = [ dependencies = [ hypothesis lark libcst ]; nativeCheckInputs = [ black parso pytestCheckHook pytest-cov-stub pytest-xdist ]; pytestFlagsArray = [ "-v" ]; disabledTests = [ # https://github.com/Zac-HD/hypothesmith/issues/21 # super slow "test_source_code_from_libcst_node_type" ]; disabledTestPaths = [ # missing blib2to3 "tests/test_syntactic.py" ]; pythonImportsCheck = [ "hypothesmith" ]; meta = with lib; { Loading pkgs/development/python-modules/hypothesmith/remove-black.patchdeleted 100644 → 0 +0 −87 Original line number Diff line number Diff line diff --git a/tests/test_cst.py b/tests/test_cst.py index 8532240..bdba2d7 100644 --- a/tests/test_cst.py +++ b/tests/test_cst.py @@ -3,7 +3,6 @@ import ast from inspect import isabstract from operator import attrgetter -import black import libcst import parso import pytest @@ -51,27 +50,6 @@ def test_ast_unparse_from_nodes(source_code): assert ast.dump(first) == ast.dump(second) -@pytest.mark.xfail -@example("A\u2592", black.Mode()) -@given( - source_code=hypothesmith.from_node(), - mode=st.builds( - black.Mode, - line_length=st.just(88) | st.integers(0, 200), - string_normalization=st.booleans(), - is_pyi=st.booleans(), - ), -) -def test_black_autoformatter_from_nodes(source_code, mode): - try: - result = black.format_file_contents(source_code, fast=False, mode=mode) - except black.NothingChanged: - pass - else: - with pytest.raises(black.NothingChanged): - black.format_file_contents(result, fast=False, mode=mode) - - @given(source_code=hypothesmith.from_node()) def test_from_node_always_compilable(source_code): compile(source_code, "<string>", "exec") diff --git a/tests/test_syntactic.py b/tests/test_syntactic.py index 7fe9835..17c4f7c 100644 --- a/tests/test_syntactic.py +++ b/tests/test_syntactic.py @@ -3,7 +3,6 @@ import ast import io import tokenize -import black import blib2to3 import parso import pytest @@ -58,34 +57,6 @@ def test_ast_unparse_from_grammar(source_code): assert ast.dump(first) == ast.dump(second) -@example("\\", black.Mode()) -@example("A#\r#", black.Mode()) -@given( - source_code=hypothesmith.from_grammar(), - mode=st.builds( - black.Mode, - line_length=st.just(88) | st.integers(0, 200), - string_normalization=st.booleans(), - is_pyi=st.booleans(), - ), -) -def test_black_autoformatter_from_grammar(source_code, mode): - try: - result = black.format_file_contents(source_code, fast=False, mode=mode) - except black.NothingChanged: - pass - except blib2to3.pgen2.tokenize.TokenError: - # Fails to tokenise e.g. "\\", though compile("\\", "<string>", "exec") works. - # See https://github.com/psf/black/issues/1012 - reject() - except black.InvalidInput: - # e.g. "A#\r#", see https://github.com/psf/black/issues/970 - reject() - else: - with pytest.raises(black.NothingChanged): - black.format_file_contents(result, fast=False, mode=mode) - - @given(source_code=hypothesmith.from_grammar("eval_input")) def test_eval_input_generation(source_code): compile(source_code, filename="<string>", mode="eval") Loading
pkgs/development/python-modules/hypothesmith/default.nix +10 −23 Original line number Diff line number Diff line { lib, black, buildPythonPackage, fetchPypi, hypothesis, Loading @@ -7,59 +8,45 @@ libcst, parso, pytestCheckHook, pytest-cov-stub, pytest-xdist, pythonOlder, setuptools, }: buildPythonPackage rec { pname = "hypothesmith"; version = "0.3.3"; format = "setuptools"; pyproject = true; disabled = pythonOlder "3.8"; disabled = pythonOlder "3.9"; src = fetchPypi { inherit pname version; hash = "sha256-lsFIAtbI6F2JdSZBdoeNtUso0u2SH9v+3C5rjOPIFxY="; }; patches = [ ./remove-black.patch ]; build-system = [ setuptools ]; postPatch = '' substituteInPlace setup.py \ --replace "lark-parser" "lark" substituteInPlace tox.ini \ --replace "--cov=hypothesmith" "" \ --replace "--cov-branch" "" \ --replace "--cov-report=term-missing:skip-covered" "" \ --replace "--cov-fail-under=100" "" ''; propagatedBuildInputs = [ dependencies = [ hypothesis lark libcst ]; nativeCheckInputs = [ black parso pytestCheckHook pytest-cov-stub pytest-xdist ]; pytestFlagsArray = [ "-v" ]; disabledTests = [ # https://github.com/Zac-HD/hypothesmith/issues/21 # super slow "test_source_code_from_libcst_node_type" ]; disabledTestPaths = [ # missing blib2to3 "tests/test_syntactic.py" ]; pythonImportsCheck = [ "hypothesmith" ]; meta = with lib; { Loading
pkgs/development/python-modules/hypothesmith/remove-black.patchdeleted 100644 → 0 +0 −87 Original line number Diff line number Diff line diff --git a/tests/test_cst.py b/tests/test_cst.py index 8532240..bdba2d7 100644 --- a/tests/test_cst.py +++ b/tests/test_cst.py @@ -3,7 +3,6 @@ import ast from inspect import isabstract from operator import attrgetter -import black import libcst import parso import pytest @@ -51,27 +50,6 @@ def test_ast_unparse_from_nodes(source_code): assert ast.dump(first) == ast.dump(second) -@pytest.mark.xfail -@example("A\u2592", black.Mode()) -@given( - source_code=hypothesmith.from_node(), - mode=st.builds( - black.Mode, - line_length=st.just(88) | st.integers(0, 200), - string_normalization=st.booleans(), - is_pyi=st.booleans(), - ), -) -def test_black_autoformatter_from_nodes(source_code, mode): - try: - result = black.format_file_contents(source_code, fast=False, mode=mode) - except black.NothingChanged: - pass - else: - with pytest.raises(black.NothingChanged): - black.format_file_contents(result, fast=False, mode=mode) - - @given(source_code=hypothesmith.from_node()) def test_from_node_always_compilable(source_code): compile(source_code, "<string>", "exec") diff --git a/tests/test_syntactic.py b/tests/test_syntactic.py index 7fe9835..17c4f7c 100644 --- a/tests/test_syntactic.py +++ b/tests/test_syntactic.py @@ -3,7 +3,6 @@ import ast import io import tokenize -import black import blib2to3 import parso import pytest @@ -58,34 +57,6 @@ def test_ast_unparse_from_grammar(source_code): assert ast.dump(first) == ast.dump(second) -@example("\\", black.Mode()) -@example("A#\r#", black.Mode()) -@given( - source_code=hypothesmith.from_grammar(), - mode=st.builds( - black.Mode, - line_length=st.just(88) | st.integers(0, 200), - string_normalization=st.booleans(), - is_pyi=st.booleans(), - ), -) -def test_black_autoformatter_from_grammar(source_code, mode): - try: - result = black.format_file_contents(source_code, fast=False, mode=mode) - except black.NothingChanged: - pass - except blib2to3.pgen2.tokenize.TokenError: - # Fails to tokenise e.g. "\\", though compile("\\", "<string>", "exec") works. - # See https://github.com/psf/black/issues/1012 - reject() - except black.InvalidInput: - # e.g. "A#\r#", see https://github.com/psf/black/issues/970 - reject() - else: - with pytest.raises(black.NothingChanged): - black.format_file_contents(result, fast=False, mode=mode) - - @given(source_code=hypothesmith.from_grammar("eval_input")) def test_eval_input_generation(source_code): compile(source_code, filename="<string>", mode="eval")