Skip to content

Commit

Permalink
python312Packages.libcst: move tests to passthru.tests (#338508)
Browse files Browse the repository at this point in the history
  • Loading branch information
dotlambda authored Sep 6, 2024
2 parents 546d20c + 0e0552e commit 4f213fe
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 135 deletions.
33 changes: 10 additions & 23 deletions pkgs/development/python-modules/hypothesmith/default.nix
Original file line number Diff line number Diff line change
@@ -1,65 +1,52 @@
{
lib,
black,
buildPythonPackage,
fetchPypi,
hypothesis,
lark,
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; {
Expand Down
87 changes: 0 additions & 87 deletions pkgs/development/python-modules/hypothesmith/remove-black.patch

This file was deleted.

54 changes: 29 additions & 25 deletions pkgs/development/python-modules/libcst/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
stdenv,
buildPythonPackage,
fetchFromGitHub,
callPackage,
cargo,
hypothesis,
hypothesmith,
libcst,
libiconv,
pytestCheckHook,
python,
Expand All @@ -16,14 +18,15 @@
setuptools-scm,
typing-extensions,
typing-inspect,
ufmt,
}:

buildPythonPackage rec {
pname = "libcst";
version = "1.4.0";
format = "pyproject";
pyproject = true;

disabled = pythonOlder "3.7";
disabled = pythonOlder "3.9";

src = fetchFromGitHub {
owner = "instagram";
Expand All @@ -41,60 +44,61 @@ buildPythonPackage rec {

cargoRoot = "native";

postPatch = ''
# avoid infinite recursion by not formatting the release files
substituteInPlace libcst/codegen/generate.py \
--replace '"ufmt"' '"true"'
'';

nativeBuildInputs = [
build-system = [
setuptools-rust
setuptools-scm
];

nativeBuildInputs = [
rustPlatform.cargoSetupHook
cargo
rustc
];

buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];

propagatedBuildInputs = [
dependencies = [
typing-extensions
typing-inspect
pyyaml
];

nativeCheckInputs = [
hypothesis
hypothesmith
pytestCheckHook
ufmt
];

preCheck = ''
# otherwise import libcst.native fails
cp build/lib.*/libcst/native.* libcst/
${python.interpreter} -m libcst.codegen.generate visitors
${python.interpreter} -m libcst.codegen.generate return_types
# Can't run all tests due to circular dependency on hypothesmith -> libcst
rm -r {libcst/tests,libcst/codegen/tests,libcst/m*/tests}
# import from $out instead
rm libcst/__init__.py
'';

disabledTests = [
# No files are generated
"test_codemod_formatter_error_input"
# FIXME package pyre-test
"TypeInferenceProviderTest"
# we'd need to run `python -m libcst.codegen.generate all` but shouldn't modify $out
"test_codegen_clean_visitor_functions"
];

# circular dependency on hypothesmith and ufmt
doCheck = false;

passthru.tests = {
pytest = libcst.overridePythonAttrs { doCheck = true; };
};

pythonImportsCheck = [ "libcst" ];

meta = with lib; {
meta = {
description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
homepage = "https://github.com/Instagram/libcst";
changelog = "https://github.com/Instagram/LibCST/blob/v${version}/CHANGELOG.md";
license = with licenses; [
license = with lib.licenses; [
mit
asl20
psfl
];
maintainers = [ ];
maintainers = with lib.maintainers; [ dotlambda ];
};
}

0 comments on commit 4f213fe

Please sign in to comment.